Company: Postmark_2nov
Difficulty: medium
Find the Substring Problem Description 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 letters (a-z). The pattern searchPattern consists of lowercase letters and may include a single wildcard character * , which matches any one character. For 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 // 'ab*de' matches 'abcde' starting at index 1. Complete the function firstOccurrence in the editor. Parameters: string text : The text to search. string searchPattern : The pattern to search for. Returns: int : The zero-based index of the first occurrence of string searchPattern in text . If searchPattern is not in text , return -1 instead. The function signature is: function firstOccurrence(text, searchPattern) { // Function body to be implemented } Examples Example 1: Inp