Problem Statement | |||||||||||||
You were hired to manage a forthcoming tournament. Each player will play against each of all the other players. According to the rules, the matches can be played in any order, but the audience will want to know the current leader at any point in time. You will be given a String[] matches. All elements of matches will be in the form "playerA defeats playerB" (quotes for clarity only). Your method should return the leader after this set of matches. The leader is a player who has played at least one match and has the highest ratio of winning matches to total matches played. In case of a tie, return the player whose name comes first lexicographically. The players' names are case sensitive (i.e. uppercase letters are lexicographically earlier than lowercase letters). | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | matches will contain between 1 and 50 elements inclusive. | ||||||||||||
- | Each element of matches will be in the form "playerA defeats playerB". | ||||||||||||
- | In each element of matches playerA will differ from playerB. | ||||||||||||
- | There will not be two elements of matches with the same players. | ||||||||||||
- | Each playerA and playerB will contain between 1 and 20 letters ('A'-'Z', 'a'-'z'), inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|