Two Strings

Given two string A and B consisting of lowercase English alphabets.
Consider all subsequences of A that are equal to string B.
You have to find whether each character(each index) of string A occurs in at least one of these subsequences.

Return 1 if each character(each index) of string s occurs in at least one of these subsequences, Else return 0.

Note: Yor solution will run on multiple test cases. Make sure to clear global variable each time.



Input Format

The only argument given is the integer array A.

Output Format

Return 1 if each character(each index) of string s occurs in at least one of these subsequences, Else return 0.

Constraints

1 <= |A| <= 100000
1 <= |B| <= 100000

For Example

Input 1:
    A = "abab"
    B = "ab"
Output 1:
    1
    total possible subsequences in A that are equal to B
     A[0]A[1]
     A[0]A[3]
     A[2]A[3]
   All indexes occurs atleast once in all of these subsequences.

Input 2:
    A = "abacaba"
    B = "aba"
    
Output 2:
    0
    total possible subsequences in A that are equal to B
     A[0]A[1]A[2]
     A[0]A[1]A[4]
     A[0]A[1]A[6]
     A[0]A[5]A[6]
     A[2]A[5]A[6]
     A[4]A[5]A[6]
     
     Index 3 does not occur in any of these subsequences.
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.
Start solving Two Strings on Interview Code Editor
Sign Up
to access hints and editorial solutions for Two Strings

Discussion


Loading...
Click here to start solving coding interview questions