Neosify - Buy, Stake & Earn Crypto
Neosify - Buy, Stake & Earn Crypto
Neosify - Buy, Stake & Earn Crypto
Dcoder logo

String Matching @ Dcoder

By Lochard | As a newbie programmer | 10 Mar 2023


Problem: Cody has a sequence of characters N. He likes a sequence if it contains his favourite sequence as a substring.

Given the sequence and his favourite sequence F, check whether the favourite sequence is present in the sequence.

Input: The first line of input contains a single line T, which represents the number of test cases. 

Each test case consists of 2 strings separated by space N and F respectively.

Output: Print "Yes" if the sequence contains the favorite sequence in it, otherwise print "No".

Constraints: 1<=T<=10.

1<=|N|,|F|<=100.

All the characters are lowercase alphabets.

Sample Input: 2

abcde abc

pqrst pr

Sample Output: 

Yes

No

for i in range(int(input())):
  n, f = input().split()
  print('Yes' if f in n else 'No')

How do you rate this article?

2


Lochard
Lochard

Asylum seeker in Lithuania. My short-lifed daily on GitHub https://github.com/locharp/asylum_daily/tree/main/en


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.