Players Scoring Lower — Segment Tree / Fenwick
For each player, tally how many players have a lower score than theirs, returning the counts in the original lobby order.
Segment Tree / Fenwick · Easy
The problem
You get a list of scores, one per player. For every player, count how many other players have a strictly lower score. Return the counts in the same order as the scores.
The story
A game lobby has 1 to 400 players, each with a score from 0 to 9, and several players may share a score. The lobby shows every player how many other players scored strictly lower than they did. Return those counts in the same order as the players.
What to return
- Return a list where entry i is how many scores in the list are strictly lower than scores[i].
- Large hidden tests (up to 400 players) run under a step budget of executed lines.
Constraints
- 1 <= scores.length <= 400
- 0 <= scores[i] <= 9
- Your code may run at most 4,888 counted steps on the largest case.
Example
- Input
scores = [8, 1, 2, 2, 3]- Output
[4, 0, 1, 1, 3]