Question: Debug the code class StockPrice { public: map mp; multiset ms; StockPrice () { } void update(int timestamp, int price) { if(mp.find(timestamp) !=mp.end()) } int
Debug the code
class StockPrice { public: map mp; multiset ms; StockPrice () { } void update(int timestamp, int price) { if(mp.find(timestamp) !=mp.end()) } int { } } auto it=ms.find(mp[timestamp]); ms.erase(it); } int current() { mp[timestamp]=price; ms.insert (price); auto it=mp.end(); it- -; return it->second; maximum () { auto it=ms.end(); return *it; } int minimum() { auto it=ms.begin(); // it--; return *it; }; /** * Your StockPrice object will be instantiated and called as such: * StockPrice* obj = new StockPrice(); * obj->update (timestamp, price); * int param_2 = obj->current(); * int param_3 = obj->maximum(); * int param_4 = obj->minimum(); */
Step by Step Solution
3.35 Rating (155 Votes )
There are 3 Steps involved in it
CODE IN C class StockPrice public map rec multiset count void updateint t int p if recfindt recend c... View full answer
Get step-by-step solutions from verified subject matter experts
