puneeth N

puneeth N

  • NA
  • 41
  • 2.2k

Now you are going to help John find out if he can form the given word

Oct 6 2021 8:09 AM

John is a 5-year-old kid who is eager to learn English words. Recently he has learnt all the alphabets and now he wants to learn English words. Anne, John's mother has a bucket of alphabets and she decided to teach her child English words using a new method. Anne’s plan is to use the bucket of alphabets to make him learn English words, she will tell the word to John and he has to pick the alphabets from the bucket to make that word. Now you are going to help John find out if he can form the given word with the bucket of alphabets that Anne has given to John. Your program should print "YES" if John can form the given word with the given bucket of alphabets and "NO" if John cannot form the given word with the given bucket of alphabets. Note: All alphabets and words are in upper case. Alphabets in the bucket can be duplicates. If a word has duplicate letters, for example "PARROT". Then the bucket of alphabets should have 2 'R' to decide this word to be "YES" in the output.

Input: Line 1 - English alphabets in bucket with comma separated Line

2 - No of words(n) that Anne going to give to John

next n lines - words that Anne gave to John Output: n lines of "YES" or "NO"

Example 1: Input: H, F, B, A, C, L, K, G, V, C, B, I, U, K, F 1 BLACKBUCK

Output: YES Explanation: The bucket of alphabets has all the letters in the given word "BLACKBUCK" so the output is "YES" Example 2: Input: Q, W, E, R, T, Y, U, I, O, P, A, S, D, F, G, H, B, N, L, U, Y, T, U, E, W, M 2 AWESOME INSIGHT Output: YES NO