Not everyone probably knows that Nivin has younger brother Nithin. Currently Nithin learns to read.
He knows some subset of the letter of Latin alphabet. In order to help Nithin to study, Nivin gave him a book with the text consisting of N words. Nithin can read a word if it consists only of the letters he knows.
Now Nivin is curious about which words his brother will be able to read, and which are not. Please help him!
Input:
The first line of the input contains a lowercase Latin letter string S, consisting of the letters Nithin can read.
The second line of the input contains an integer N denoting the number of words in the book.
Each of the following N lines contains a single lowecase Latin letter string Wi, denoting the ith word in the book
Output:
For each of the words, output "Yes" (without quotes) in case Nithin can read it, and "No" (without quotes) otherwise.
#include <stdio.h> #include <string.h> int main() { char string[100];char search[100]; int t,i,j,len,c=0; scanf("%s",string); len=strlen(string); scanf("%d",&t); while(t--){ c=0; scanf("%s",search); for(i=0;i<=strlen(string)-1;i++) { for(j=0;j<=strlen(search)-1;j++) { if(string[i]==search[j]){ c++;break;} } } if(c==len) printf("Yes\n"); else printf("No\n"); } return 0; }
INPUT_1:
mat
2
rat
vat
OUTPUT:
No
No
INPUT_2:
not
3
ton
ten
don
OUTPUT:
Yes
No
No
ILLUSTRATION
Morae Q!
- Conversion of days into year, weeks and days.
- Find if the number is a perfect number or not.
- Compute conversion of Binary to Octal.
- Return the sum of digits in a number.
- Find if a word exists or not in a sentence.
- Convert Numbers into Words.
- Read a word if it consists only of the letters known.
- Check if the string is a dynamic string or not.
- Convert all Uppercase letters to Lowercase and vice-versa.
- Change the string such that there are no matching adjacent characters.
- Find the number of sub-strings which start and end both in 1.
- Find the start and end index of unsorted sub-array.
- Find the maximum number of pairs that can be formed.
- Figure out the number of bubbly words present.
- Check if a string is lapindrome or not even with a middle character.
- Seating layout in a triangular shaped class according to the number of rows.
- Find and Sort a sub-array which makes whole array sorted.
- Seating layout according to the number of rows.
- Find the final states of the bulbs.
- Check if reversing sub array makes the array sorted.