All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : May 22, 2024
Last updated : July 01, 2024
Related Topics : Two Pointers, String, String Matching
Acceptance Rate : 43.74 %
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
try :
return haystack.index(needle)
except Exception as e:
return -1