Problem 61092. Leaderboard Tracker
- S is an m×n matrix of scores, where S(i,j) is the score of player j in match i.
- cumScore is an m×1 vector containing the cumulative score of the current leader after each match.
- leaderIdx is an m×1 vector of indices of the current leader.
Example:
S = [2 3 1; 1 2 3; 0 1 2];
[cumScore, leaderIdx] = leaderboard_tracker(S)
% cumScore = [3;5;6]
% leaderIdx = [2;2;2]
Hints:
- Use cumsum to track cumulative scores.
- Update the leader only if a player’s cumulative score exceeds the current leader.
- In case of ties for a new leader, pick the lowest index.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
6 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!