Computer Science, asked by rabi3bhat, 7 hours ago

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 separate

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​

Answers

Answered by fayyaztolhr
3

Answer:

2

AWESOME

INSIGHT

Output

Explanation:

sorry for spamming thanks ❤️❤️

Answered by sourasghotekar123
0

Explanation:

Note: All alphabets and words are in upper case. Alphabets in the bucket can be duplicates. If a word has duplicate letters,

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

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

a)AWESOME

b)INSIGHT

Explanation: The bucket of alphabets has all the letters in the given word  AWESOME so the output is "YES"

 Explanation: The bucket of alphabets hasn't  all the letters in the given word  INSIGHT ,I is repeated 2 times but in the bucket only one I is present . so the output is "NO"

 

The project code is #SPJ3

Similar questions