Get Average Standing π
As an aspiring developer, you are required to develop a result analysis service for a car game on Amazon games.
There are n even records of d players who participated in different events in form of [race id, player's id, player's time]. For some race id, a player's ranking id decided based on the increasing order of their finish time. If two players have the same finish time, the one with a lower id is ranked lower.
The average standing of any player is the average of their various positions in all the races they competed in, expressed in the form of a fraction p/q. If there are multiple possible such fractions, reduce them such that p is the minimum possible.
Return a 2-dimensional array where each element i contains the ith player's p and q as described above. If the player did not compete in any races, the player's p and q values are both -1.
Complete the function getAverageStanding which has the following parameters:
int d: the number of playersint records[n][3]: each record[i] contains [race id, player id, player time]
1Example 1
Constraints
Limits and guarantees your solution can rely on.
N/A (If you know it, feel free to let us know ^^ tyvm!