/ leetcodesolve / findstring.py
swadhinbiswas coading · 3/29/2024
d1cc7a6
13 lines · 265 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution:
    def strStr(self, haystack: str, needle: str) -> int:
      if needle == '':
        return -1
      else:
        return haystack.find(needle)



haystack = "hello"
needle = "ll"
solution = Solution()
print(solution.strStr(haystack, needle)) # 2