MCPcopy Index your code
hub / github.com/neetcode-gh/leetcode / next

Method next

java/0901-online-stock-span.java:8–14  ·  view source on GitHub ↗
(int price)

Source from the content-addressed store, hash-verified

6 }
7
8 public int next(int price) {
9 int span=1;
10 while(!s.isEmpty() && s.peek()[0]<=price)
11 span+=s.pop()[1];
12 s.push(new int[]{price,span});
13 return span;
14 }
15}

Callers 1

evictLeastFrequentMethod · 0.45

Calls 4

isEmptyMethod · 0.45
peekMethod · 0.45
popMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected