Company: TSMC
Difficulty: medium
Question 3 Given s and x, determine the zero-based index of the first occurrence of x in s. String s consists of lowercase letters in the range ascii[a-z]. String x consists of lowercase letters and may also contain a single wildcard character, *, that represents any one character . Function Description Complete the function firstOccurrence in the editor below. The function must return an integer denoting the zero-based index of the first occurrence of string x in s. If x is not in s, return -1 instead. Parameters: string s : a string of lowercase letters string x : a string of lowercase letters which may contain 1 instance of the wildcard character * Returns: int : the index of the first occurrence, or -1 if x does not occur in s Constraints 1 ≤ length of s ≤ 5 × 10 5 1 ≤ length of x ≤ 1000 Example s = \"xabcdey\" x = \"ab*de\" The first match is at index 1. s x a b c d e y x a b * d e Index 0 1 2 3 4 5 6 Input Format for Custom Testing Input from stdin will be processed as follows an