We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7cd1668 commit dbe9db4Copy full SHA for dbe9db4
Heap/2102.Sequentially-Ordinal-Rank-Tracker/2102.Sequentially-Ordinal-Rank-Tracker_v1.cpp
@@ -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