Two words are said to be anagrams if one word can be formed by rearranging the letters of the other word. For example, "AABC" and "CABA" are anagrams.
You will be given two Strings, word1 and word2, representing two words. These two strings will contain only uppercase letters ('A'-'Z') and '.' characters which denote missing letters. Replace the '.' characters with uppercase letters such that the two words become anagrams and return the result as a String[] containing exactly two elements. The first element should correspond to word1 and the second element should correspond to word2. If there are multiple possible return values, choose the one in which the first element comes first alphabetically. If ties still exist, choose the one among them in which the second element comes first alphabetically. If it is impossible to make the two words into anagrams, return an empty String[]. Note that two equal words are considered anagrams.
|