ModI WISH

3.7

33 votes
Easy-Medium
Problem

Delegates from 26 countries (delegates denoted by lowercase English alphabets 'a-z' and countries by lowercase English alphabets( 'a-z') have been invited for the Independence Day Parade. It is the Prime Minister's wish that the delegates be seated in a specific order according to their countries. Given the seating arrangement find if its according to the Prime Minister's wish.

INPUT:
The first line contains the number of test cases T.Each test case contains two lines each of which contains a single string. The first line denotes the actual seating arrangement S and the second line denotes the order of countries O.

OUTPUT:
For each test case, on a separate line, print "YES" if the seating arrangement is in accordance with the wish, else print "NO".

CONSTRAINTS:
1<=t<=10000
1<=S<=106
1<=O<=26

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Test Case 1: We have a delegate from country 'l' in the seating arrangement after the delegate from country 'o'. So the seating arrangement is against the wish.

Test Case 2: 'd' in the given string "helloworld" is after 'o', so the order is not followed.

Test Case 3: All delegates are seating according to the wish.

Editor Image

?