import java.util.Stack;
class StockSpanner {
private Stack<StackElemnet> stack = new Stack<>();
public StockSpanner() {
}
public int next(int price) {
int count = 1;
while (!stack.empty()&&price>=stack.peek().price){
StackElemnet top = stack.pop();
count +=top.count;
}
StackElemnet stackElemnet = new StackElemnet();
stackElemnet.price = price;
stackElemnet.count =count;
stack.push(stackElemnet);
return count;
}
}
class StackElemnet{
int price;
int count;
}
/**
* Your StockSpanner object will be instantiated and called as such:
* StockSpanner obj = new StockSpanner();
* int param_1 = obj.next(price);
*/