Check if the Word is present in Sentence or not
You have been given a sentence ‘S’ in the form of a string and a word ‘W’, you need to find whether the word is present in the given sentence or not. The word must be present as a complete string in the sentence and not a substring of some other word.
Note:
1. All the characters in the string and the word are in lowercase.
2. Length of the sentences and the words will always be greater than zero.
3. Words in the sentence will be separated by spaces.
Input Format :
The first line of the input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains the sentence ‘S’.
The second line of each test case contains the word ‘W’.
Output Format :
The only line of output of each test case should print “Yes” if the word ‘W’ is present in the sentence ‘S’, else print “No”.
The output of each test case will be printed in a separate line.
Note: You are not required to print the expected output; it has already been taken care of. Just implement the function.
Constraints :
1 <= T <= 50
1 <= |S|, |W| <= 10000
Where ‘T’ is the number of test cases, ‘S’ and ‘W’ are strings as described in the problem statement.
Time limit: 1 sec
Be the first one to answer
Add answer anonymously...
Popular interview questions of Software Engineer Intern
>
UnitedHealth Software Engineer Intern Interview Questions
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