Given a string str and another string patt. Find the first position (considering 0-based indexing) of the character in patt that is present at the minimum index in str.
Input: str = geeksforgeeks patt = set Output: 1 Explanation: e is the character which is present in given patt "geeksforgeeks" and is first found in str "set". First Position of e in str is 1.
Input: str = adcffaet patt = onkl Output: -1 Explanation: There are none of the characters which is common in patt and str.
You only need to complete the function minIndexChar() that returns the index of answer in str or returns -1 in case no character of patt is present in str.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(Number of distinct characters).
1 ≤ |str|,|patt| ≤ 105
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes