
Asked in Cisco
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...
Top Consultant Engineer Interview Questions Asked at Cisco
Q. Can you describe how a website sends data to a server?
Q. Covid Vaccination Distribution Problem As the Government ramps up vaccination dr...read more
Q. What was the topic of the video you had to submit for your assignment?
Interview Questions Asked to Consultant Engineer at Other Companies
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

