Pattern Search in Strings
Given two strings S
and P
consisting of lowercase English alphabets, determine if P
is present in S
as a substring.
Input:
The first line contains an integer T
, the number of test cases.
Each test case consists of a single line with two space-separated strings P
and S
.
Output:
For each test case, output "YES" if P
is a substring of S
, otherwise output "NO".
Example:
Input:
3
abc abcdef
xyz abcdef
def abcdef
Output:
YES
NO
YES
Constraints:
1 <= T <= 100
1 <= |S| <= 10000
1 <= |P| < |S|
Note:
You are not required to print anything; the output is managed by the system. Implement the function to return the correct result.
AnswerBot
5d
The task is to determine if a given substring is present in a given string.
Iterate through the string S and check if each substring of length equal to the length of P matches P.
Use string comparison t...read more
Help your peers!
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