Skip to content

Commit dbe9db4

Browse files
authored
Create 2102.Sequentially-Ordinal-Rank-Tracker_v1.cpp
1 parent 7cd1668 commit dbe9db4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class SORTracker {
2+
set<pair<int,string>>Set;
3+
set<pair<int,string>>::iterator iter;
4+
public:
5+
SORTracker()
6+
{
7+
Set.insert({INT_MIN, ""});
8+
iter = Set.begin();
9+
}
10+
11+
void add(string name, int score)
12+
{
13+
Set.insert({-score, name});
14+
if (make_pair(-score, name) < *iter)
15+
iter = prev(iter);
16+
}
17+
18+
string get()
19+
{
20+
iter = next(iter);
21+
return iter->second;
22+
}
23+
};
24+
25+
/**
26+
* Your SORTracker object will be instantiated and called as such:
27+
* SORTracker* obj = new SORTracker();
28+
* obj->add(name,score);
29+
* string param_2 = obj->get();
30+
*/

0 commit comments

Comments
 (0)