Implement strStr() 🚕
Given two strings
haystack, return the index of the first occurrence of
needle is not part of
What should we return when
needle is an empty string? This is a great question to ask during an interview.
Input: haystack = "hello", needle = "ll"
Input: haystack = "aaaaa", needle = "bba"
1 <= haystack.length, needle.length <= 104
needleconsist of only lowercase English characters.
I don’t know the space and time complexity because I'm using a library function.
Time Complexity O(n*m) where n is the length of the needle and m is the length of the haystack.
Space Complexity O(1)
Do you see that green follow button? 🐌