Hard · System Design
Sequentially Ordinal Rank Tracker
Implement SORTracker: add(name, score) records a scenic location, and get() returns the name of the i-th best location added so far, where i counts the get calls including this one; higher scores rank first and equal scores rank by the lexicographically smaller name.
Examples
Example 1
{
"ops": [
{"kind": "add", "name": "bradford", "score": 2},
{"kind": "add", "name": "branta", "score": 3},
{"kind": "add", "name": "alameda", "score": 3},
{"kind": "get"},
{"kind": "get"}
]
}Output: ["alameda", "branta"]
Example 2
{
"ops": [
{"kind": "add", "name": "aurora", "score": 5},
{"kind": "add", "name": "bravo", "score": 5},
{"kind": "add", "name": "alpine", "score": 4},
{"kind": "get"}
]
}Output: ["aurora"]
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.