TopCoder problem "Secretary" used in TCHS SRM 40 (Division I Level One)



Problem Statement

    You recently asked your secretary to put some box files into storage for you. He was supposed to sort them with the names of the files in lexicographical order, but an error with the printer caused the names to be printed with the characters in reverse order and he sorted them based on the printed names. You want to know what order the files ended up in.



You will be given the original names of the files in a String[] files. Return a String containing the original name of the first file in the order your secretary sorted them.
 

Definition

    
Class:Secretary
Method:wrongOrdering
Parameters:String[]
Returns:String
Method signature:String wrongOrdering(String[] files)
(be sure your method is public)
    
 

Constraints

-files will contain between 1 and 50 elements, inclusive.
-Each element of files will contain between 1 and 50 characters, inclusive.
-files will contain only uppercase letters ('A'-'Z').
 

Examples

0)
    
{"JAMES","PETER","ADAM","JOHN","DAVE","EDWARD"}
Returns: "EDWARD"
These are your employee records that the secretary is sorting. The order in which your secretary sorted them is:



DRAWDE - EDWARD

EVAD - DAVE

MADA - ADAM

NHOJ - JOHN

RETEP - PETER

SEMAJ - JAMES



"EDWARD" is the first file in the list.
1)
    
{"ALGORITHM","DESIGN","DEVELOPMENT","TCHS","STUDIO","MARATHON"}
Returns: "ALGORITHM"
2)
    
{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"}
Returns: "A"
3)
    
{"ACCOUNTING"
,"MARKETING"
,"PERSONNEL"
,"FINANCE"
,"SALES"
,"ADMINISTRATION"
,"IT"
,"MANAGEMENT"
,"OPERATIONS"
,"LEGAL"
,"PURCHASING"
,"LOGISTICS"
,"TRAINING"
,"TECHNICAL"}
Returns: "FINANCE"
4)
    
{"AAAAA","AA","AAA"}
Returns: "AA"

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10784&pm=8055

Writer:

StevieT

Testers:

PabloGilberto , brett1479 , Olexiy , ivan_metelsky

Problem categories:

Sorting, String Manipulation