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 codeclass StockPrice { public: map mp; multiset ms; StockPrice () { }

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

1 Expert Approved Answer
Step: 1 Unlock

CODE IN C class StockPrice public map rec multiset count void updateint t int p if recfindt recend c... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!