We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fbf5c6f commit 1dd83e6Copy full SHA for 1dd83e6
best-time-to-buy-and-sell-stock/hyogshin.py
@@ -0,0 +1,8 @@
1
+class Solution:
2
+ def maxProfit(self, prices: List[int]) -> int:
3
+ dp = [0] * (len(prices) + 1)
4
+ least_num = prices[0]
5
+ for i in range(len(prices)):
6
+ least_num = min(prices[i], least_num)
7
+ dp[i] = max(prices[i] - least_num, dp[i-1])
8
+ return max(dp)
0 commit comments