标签:obj next 大于 inf tco pop 不为 private called
class StockSpanner { public: StockSpanner() { } int next(int price) { int d=1; while(!value.empty()&&price>=value.top())//价格栈不为空且当前的价格大于等于价格栈的顶元素 { d+=get.top();//当前跨度为1加上跨度顶的元素 value.pop(); get.pop();//每个栈删去栈顶元素 } value.push(price);//每次存价格进去 get.push(d);//把对应的跨度存进去 return d; } private: stack<int>value; stack<int>get; }; /** * Your StockSpanner object will be instantiated and called as such: * StockSpanner* obj = new StockSpanner(); * int param_1 = obj->next(price); */
标签:obj next 大于 inf tco pop 不为 private called
原文地址:https://www.cnblogs.com/Vampire6/p/13121944.html