Company: Crayondata_14nov
Difficulty: medium
Hack Number Problem Description For each query you are given a sentence S1 , made of English letters and single spaces, a string S2 , made of English letters only, a character C , either 'Y' or 'N' , an integer I , a starting position in S1 . The Hack number is the smallest index p with p >= I at which S2 occurs in S1 , subject to the flag C : when C is 'Y' the occurrence must be a complete word: the character immediately before it must be a space, or the occurrence must start at the beginning of S1 , and the character immediately after it must be a space, or the occurrence must end at the end of S1 ; when C is 'N' there is no such condition, so the occurrence may sit inside a longer word. If no occurrence satisfies this, the Hack number does not exist. All indices, including I and the Hack number, are 0 -based and count every character of S1 , spaces included. Matching is case sensitive. Implement getMinNumber(text, search, wholeWord, start) , which returns the Hack number, or -1 w