Company: DIT intern hiring test
Difficulty: medium
Find the Substring Given a string text and a pattern searchPattern , find the zero-based index of the first occurrence of searchPattern in text . The string text contains only lowercase English letters (a-z). The pattern searchPattern consists of lowercase English letters and may include a single wildcard character * , which matches any one character. An occurrence of searchPattern at index i means that for every position j of the pattern, either searchPattern[j] is * , or text[i + j] equals searchPattern[j] . The whole pattern must fit inside text . Example text = "xabcdey" searchPattern = "ab*de" The first match is at index 1. text x a b c d e y searchPattern a b * d e Index 0 1 2 3 4 5 6 Function Description Complete the function firstOccurrence in the editor, with the following parameters: string text : the text to search string searchPattern : the pattern to search for Return int : the zero-based index of the first occurrence of string searchPattern in text . If searchPattern is n