Problem Statement | |||||||||||||
My friends have accepted an invitation to my party. I need to sort them into
"popularity order" which means that
the ones with more popular first names
are earlier on the list. In case of ties, I'll list the ones who replied
earlier to my invitation earlier in my popularity order. (The popularity of
a first name is equal to how many of my friends have the same first name.)
I have a String[] reply that lists the names in order of their reply. The k-th element is the k-th one who replied to the invitation. Each name is given as the first name, followed by a single space, followed by the last name, all in uppercase letters. Given reply return a String[] containing the names from reply in the desired order. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | reply will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of reply will contain between 3 and 50 characters, inclusive. | ||||||||||||
- | Each element of reply will contain only uppercase letters ('A'-'Z') and exactly one space, neither leading nor trailing. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
|