File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ #ifdef _WIN32
2+ #include " _[1,2]toVector.h"
3+ #endif
4+
5+ class StockPrice {
6+ private:
7+ unordered_map<int , int > ma;
8+ multiset<int > se;
9+ int Mtime;
10+ public:
11+ StockPrice () {
12+ Mtime = 0 ;
13+ }
14+
15+ void update (int timestamp, int price) {
16+ if (ma.count (timestamp)) {
17+ se.erase (ma[timestamp]);
18+ }
19+ ma[timestamp] = price;
20+ se.insert (price);
21+ Mtime = max (Mtime, timestamp);
22+ }
23+
24+ int current () {
25+ return ma[Mtime];
26+ }
27+
28+ int maximum () {
29+ return ma[*se.end ()];
30+ }
31+
32+ int minimum () {
33+ return ma[*se.begin ()];
34+ }
35+ };
36+
37+ /* *
38+ * Your StockPrice object will be instantiated and called as such:
39+ * StockPrice* obj = new StockPrice();
40+ * obj->update(timestamp,price);
41+ * int param_2 = obj->current();
42+ * int param_3 = obj->maximum();
43+ * int param_4 = obj->minimum();
44+ */
You can’t perform that action at this time.
0 commit comments