TopCoder problem "Aaagmnrs" used in SRM 204 (Division II Level Two)



Problem Statement

    

Two phrases are anagrams if they are permutations of each other, ignoring spaces and capitalization. For example, "Aaagmnrs" is an anagram of "anagrams", and "TopCoder" is an anagram of "Drop Cote". Given a String[] phrases, remove each phrase that is an anagram of an earlier phrase, and return the remaining phrases in their original order.

 

Definition

    
Class:Aaagmnrs
Method:anagrams
Parameters:String[]
Returns:String[]
Method signature:String[] anagrams(String[] phrases)
(be sure your method is public)
    
 

Constraints

-phrases contains between 2 and 50 elements, inclusive.
-Each element of phrases contains between 1 and 50 characters, inclusive.
-Each element of phrases contains letters ('a'-'z' and 'A'-'Z') and spaces (' ') only.
-Each element of phrases contains at least one letter.
 

Examples

0)
    
{ "Aaagmnrs", "TopCoder", "anagrams", "Drop Cote" }
Returns: { "Aaagmnrs",  "TopCoder" }
The examples above.
1)
    
{ "SnapDragon vs tomek", "savants groped monk", "Adam vents prongs ok" }
Returns: { "SnapDragon vs tomek" }
2)
    
{ "Radar ghost jilts Kim", "patched hers first",
  "DEPTH FIRST SEARCH", "DIJKSTRAS ALGORITHM" }
Returns: { "Radar ghost jilts Kim",  "patched hers first" }

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=2854

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=5850&pm=2854

Writer:

vorthys

Testers:

lbackstrom , brett1479

Problem categories:

Sorting, String Manipulation