Given 2 strings of lowercase alphabets A and B of size N and M respectively.
it is guaranteed that B is a subsequence of A.
For example, the strings "test", "tst", "tt", "et" and "" are subsequences of the string "test". But the strings "tset", "se", "contest" are not subsequences of the string "test".
You need to remove some substring(contiguous subsequence) from A of maximum possible length such that after removing this substring B will remain a subsequence of A.
|If you want to remove the substring A[l::r] then the string A will be transformed to **A1A2…Al−1Ar+1Ar+2…A||A||−1A||A||** (where **||A||** is the length of A).|
Find and return the maximum possible length of the substring you can remove so that B is still a subsequence of A.
The first argument given is the string A. The second argument given is the string B.
Return the maximum possible length of the substring you can remove so that B is still a subsequence of A.
1 <= N, M <= 10^5
Input 1: A = "bbaba" B = "bb" Output 1: 3 Explaination 1: A[2::4] = "aba" can be removed and B still remains the subsequence of A[0::1] Input 2: A = "bbaba" B = "ab" Output 2: 2
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.