Skip to content

Commit cdfa265

Browse files
authoredFeb 24, 2025
Create Solution_2.py
1 parent 26c0dfe commit cdfa265

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution(object):
2+
def strStr(self, haystack, needle):
3+
"""
4+
:type haystack: str
5+
:type needle: str
6+
:rtype: int
7+
"""
8+
for i in range(len(haystack) - len(needle) +1):
9+
if haystack[i:i+len(needle)] == needle:
10+
return i
11+
12+
return -1

0 commit comments

Comments
 (0)
Please sign in to comment.