Find Pattern in String
You are given two strings 'S' and 'P' consisting of lowercase English alphabets. Your task is to find whether the 'P' is present in 'S' as a substring or not.
Note
1. There may be more than one occurrence of 'P' in 'S'.
2. Some alphabets in the strings may be repeated.
Input Format:
The first line of input contains a single integer 'T', representing the number of test cases
Then the 'T' test cases follow.
The first line of each test case contains two space-separated strings 'P' and 'S' respectively.
Output Format:
For each test case, print a single line containing “YES” if string 'P' is present in string 'S' as a substring, otherwise print “NO”.
The output for each test case will be printed in a separate line.
Note
You don’t have to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 100
1 <= |S| <= 10000
1 <= |P| < |S|
Where |S| and |P| represents the length of the string 'S' and 'P' respectively.
Time limit: 1 sec.
Be the first one to answer
Add answer anonymously...
Top Cisco Consultant Engineer interview questions & answers
Popular interview questions of Consultant Engineer
Top HR questions asked in Cisco Consultant Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app