Let 'N' = 3, 'S' = "xyz", M = 3, T = "xyz".
Bob's string on Day 1 is "xyz".
Is "xyz" a subsequence of "xyz"? Yes.
The earliest day is 1.
Thus, the answer is 1.
The first line contains two integers, 'N' and 'M'.
The second line contains the string 'S' of length 'N'.
The third line contains the string 'T' of length 'M'.
Return the earliest day (a positive integer starting from 1) when 'T' appears as a subsequence in Bob's string. If 'T' can never be formed as a subsequence, return -1.
You don’t need to print anything. Just implement the given function.
1 <= 'N', 'M' <= 10^5
'a' <= 'S', 'T' <= 'z'
Time Limit: 1 sec
Approach:
Algorithm: