Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit 5522edd

Browse files
committed
created solution for problem75
1 parent c2e136c commit 5522edd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

problem75/Solution.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class StockSpanner:
2+
3+
def __init__(self):
4+
self.stack = []
5+
6+
def next(self, price: int) -> int:
7+
span = 1
8+
9+
while self.stack and self.stack[-1]['price'] <= price:
10+
span += self.stack.pop()['span']
11+
12+
self.stack.append({'price': price, 'span': span})
13+
return span
14+
15+
16+
# Your StockSpanner object will be instantiated and called as such:
17+
# obj = StockSpanner()
18+
# param_1 = obj.next(price)

0 commit comments

Comments
 (0)