TopcoderArchiveVisit Topcoder
Archive
Algorithm problem

Secretary

Problem statement, definition, constraints, and public examples.

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

  1. {"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.
  2. {"ALGORITHM","DESIGN","DEVELOPMENT","TCHS","STUDIO","MARATHON"}
    Returns: "ALGORITHM"
  3. {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"}
    Returns: "A"
  4. {"ACCOUNTING"
    ,"MARKETING"
    ,"PERSONNEL"
    ,"FINANCE"
    ,"SALES"
    ,"ADMINISTRATION"
    ,"IT"
    ,"MANAGEMENT"
    ,"OPERATIONS"
    ,"LEGAL"
    ,"PURCHASING"
    ,"LOGISTICS"
    ,"TRAINING"
    ,"TECHNICAL"}
    Returns: "FINANCE"
  5. {"AAAAA","AA","AAA"}
    Returns: "AA"
Back to all problems