forked from vicky545/smartinterviewspreperation
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchecksubsequence.py
More file actions
30 lines (30 loc) · 734 Bytes
/
checksubsequence.py
File metadata and controls
30 lines (30 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Given 2 strings A and B, check if A is present as a subsequence in B.
Input Format
First line of input contains T - number of test cases. Its followed by T lines, each line contains 2 space separated strings - A and B.
Constraints
1 <= T <= 1000
1 <= len(A), len(B) <= 1000
'a' <= A[i],B[i] <= 'z'
Output Format
For each test case, print "Yes" if A is a subsequence of B, "No" otherwise, separated by new line.
Sample Input 0
2
data gojdaoncptdhzay
algo plabhagqogxt
Sample Output 0
Yes
No"""
n=int(input())
for _ in range(n):
a,b=input().split()
l=len(a)
m=len(b)
i=j=0
while i<l and j<m:
if a[i]==b[j]:
i+=1
j+=1
if i==l:
print("Yes")
else:
print("No")