Skip to content

Commit ab8ab3f

Browse files
author
sangbeenmoon
committed
solved best-time-to-buy...
1 parent 151579c commit ab8ab3f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# TC : O(n)
2+
# SC : O(1)
3+
4+
class Solution:
5+
def maxProfit(self, prices: List[int]) -> int:
6+
answer = 0
7+
mm = 10001
8+
9+
for price in prices:
10+
mm = min(mm, price)
11+
answer = max(answer, price - mm)
12+
13+
return answer

0 commit comments

Comments
 (0)