def test_contain_string(self): self.assertEqual(-1, contain_string("mississippi", "issipi")) self.assertEqual(0, contain_string("Hello World", "")) self.assertEqual(2, contain_string("hello", "ll"))
def test_contain_string(self): self.assertEqual(-1, contain_string("mississippi", "issipi")) self.assertEqual(0, contain_string("Hello World", "")) self.assertEqual(2, contain_string("hello", "ll"))
""" Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = "hello", needle = "ll" Output: 2 Example 2: Input: haystack = "aaaaa", needle = "bba" Output: -1 Reference: https://leetcode.com/problems/implement-strstr/description/ """ from algorithms.strings import contain_string haystack = "hello" needle = "ll" print(contain_string(haystack, needle)) haystack = "aaaaa" needle = "bba" print(contain_string(haystack, needle))