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.
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’.
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.
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
The basic idea of this approach is to check each word of the given sentence ‘S’ if it matches with the given word ‘W’.
Consider the following steps:
In the last approach, we were explicitly storing the words of the sentence in a set, but there are some in-built libraries (like stringstream in C++) that can do this on their own.( We can use split function in Python to do the same).
The stringstream breaks the sentence into words, and then we can easily check whether the given word is present or not.
Consider the following steps:
Divisible Substrings
Ninja and Numbers
Longest Palindromic Substring
Cakes
1-3 Palindrome