finish 28
This commit is contained in:
parent
6cdab826c7
commit
fe4a2064e8
12
leetcode/28.py
Normal file
12
leetcode/28.py
Normal file
@ -0,0 +1,12 @@
|
||||
"""
|
||||
Given two strings needle and haystack,
|
||||
return the index of the first occurrence of needle in haystack,
|
||||
or -1 if needle is not part of haystack.
|
||||
"""
|
||||
class Solution:
|
||||
def strStr(self, haystack: str, needle: str) -> int:
|
||||
if needle in haystack:
|
||||
return haystack.find(needle)
|
||||
else:
|
||||
return -1
|
||||
|
Loading…
x
Reference in New Issue
Block a user