Practice Sequentially Ordinal Rank Tracker
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Sequentially Ordinal Rank Tracker
Problem Statement
SORTracker starts empty. add(name,score) adds a uniquely named location. Higher scores rank first, with lexicographically smaller names breaking ties. The ith get() returns the ith best location among all entries present at that moment. Later insertions may change ranks, so the same name can be returned on multiple get calls. Practice approach: Maintain two heaps around the number of queries already served: the best i locations and the remaining locations. Keep the worst of the best partition at its root. Rebalance after insertion and grow the partition on get. An order-statistics tree also supports rank selection.
Source: Sequentially Ordinal Rank Tracker on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
["SORTracker","add","add","get","add","get","get"] [[],["beta",3],["alpha",3],[],["gamma",5],[],[]]
[null,null,null,"alpha",null,"alpha","beta"]
Alpha initially ranks first by the name tie-break. After Gamma is added, Alpha ranks second and is returned again.
Constraints
Related LeetCode Problems
Practice more problems similar to Sequentially Ordinal Rank Tracker.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.