Skip to content

Commit a6702da

Browse files
committed
901
1 parent 4d13338 commit a6702da

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

901.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class StockSpanner {
2+
stack<int>mark;
3+
stack<int>weight;
4+
5+
public:
6+
StockSpanner() {
7+
}
8+
int next(int price) {
9+
int w=1;
10+
while(!mark.empty() && mark.top() <= price){
11+
mark.pop();
12+
w=w+weight.top();
13+
weight.pop();
14+
}
15+
mark.push(price);
16+
weight.push(w);
17+
return w;
18+
}
19+
};

0 commit comments

Comments
 (0)