159. Leetcode 122. 买卖股票的最佳时机 II (贪心算法-股票题目)
生活随笔
收集整理的這篇文章主要介紹了
159. Leetcode 122. 买卖股票的最佳时机 II (贪心算法-股票题目)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
class Solution:def maxProfit(self, prices: List[int]) -> int:result = 0for i in range(1,len(prices)):result += max(prices[i]-prices[i-1],0)return result總結
以上是生活随笔為你收集整理的159. Leetcode 122. 买卖股票的最佳时机 II (贪心算法-股票题目)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 158. Leetcode 121. 买
- 下一篇: 161. Leetcode 55. 跳跃