Problem Statement | |||||||||||||
At a recent competition, each competitor received an integer score between 0 and 100, inclusive. Now, you need to rank the competitors from first to last. First place (the highest score) is ranked 1, second is ranked 2, and so on. In the event of a tie, all of the tied competitors should receive the average of the ranks they would have received if there were put in some order (it doesn't matter what order, the average is always the same). For example, if there is a tie between two people for first place, then ordering them would give one competitor rank 1, and the other rank 2. The average of these is 1.5, so both competitors receive a rank of 1.5. You should return a double[] containing the ranks of the competitors, each of whose elements corresponds to the element of score with the same index. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | scores will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of scores will be between 0 and 100, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
|