ANAGR - Anagrams
Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. In this problem you’ll be given two strings. Your job is to find if the two strings are anagrams of each other. If they are not anagrams then find the lexicographically smallest palindrome (in lowercase letters) that may be appended to the end of one of the two strings so that they become anagrams of each other.
The lower and upper case letters are considered equivalent. The number of spaces or any other punctuation is not important.
Input
The first line of the input contains a number T, the number of test cases. T test cases follow. Each test case consists of two lines, one string in each line.
Output
For each test case output a single line. Print ‘YES’ (without the quotes) if the two strings are anagrams of each other. If they are not, then print the lexicographically smallest string as discussed above. If no such string exists, then print ‘NO LUCK’ (without the quotes).
Constraints
1<=T<=100
1<=length of the strings<=100
Sample
INPUT: 4 Computer programmer mature germ romp crop Awaaay away internet web the terminator I’m rotten hater OUTPUT: YES aa NO LUCK YES
hide comments
Sanjay Kumar:
2013-12-11 19:40:33
what will be output if one of the strings is null
|
|
(test):
2013-11-26 14:55:11
Be careful, the last line does not contain a newline character. |
Added by: | Abhinav92003 |
Date: | 2013-10-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |