A corporate employee directory service ingested a batch of name records from several legacy systems, and the capitalization in each name is now inconsistent -- some are stored ALL CAPS, some in all lowercase, and some in a random mix of cases. Before republishing the directory, every name must be normalized so that exactly its first letter is uppercase and every other letter is lowercase, and the corrected records must be listed in ascending order of employee id.
Print n lines, each containing the id followed by a space and the corrected name, ordered by ascending id.
Example 1
Input
3 102 aliCE 7 BOB 15 cArL
Expected
7 Bob 15 Carl 102 Alice
Explanation
"aliCE" becomes "Alice" (first letter capitalized, rest lowercased), "BOB" becomes "Bob", and "cArL" becomes "Carl". Sorting the three records by ascending id (7, then 15, then 102) gives the printed order: 7 Bob, 15 Carl, 102 Alice.
Example 2
Input
2 5 EVE 2 dAN
Expected
2 Dan 5 Eve
Explanation
"EVE" becomes "Eve" and "dAN" becomes "Dan". Ordered by ascending id (2 before 5), the record with id 2 ("Dan") is printed first, followed by the record with id 5 ("Eve").
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →