diff --git a/leetcode/28.py b/leetcode/28.py new file mode 100644 index 0000000..0df4336 --- /dev/null +++ b/leetcode/28.py @@ -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 + \ No newline at end of file