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
4mo
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...
Cisco Consultant Engineer interview questions & answers
A Consultant Engineer was asked Q. Minimum Cost Path Problem Statement Given an N x M matrix filled with integers, ...read more
A Consultant Engineer was asked Q. Covid Vaccination Distribution Problem As the Government ramps up vaccination dr...read more
A Consultant Engineer was asked Q. Can you describe how a website sends data to a server?
Popular interview questions of Consultant Engineer
A Consultant Engineer was asked Q1. Minimum Cost Path Problem Statement Given an N x M matrix filled with integers, ...read more
A Consultant Engineer was asked Q2. Covid Vaccination Distribution Problem As the Government ramps up vaccination dr...read more
A Consultant Engineer was asked Q3. Can you describe how a website sends data to a server?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

