122.买卖股票的最佳时机II
class Solution:
def maxProfit(self, prices: List[int]) -> int:
result = 0
for i in range(len(prices)-1):
if prices[i+1] - prices[i] > 0:
result += prices[i+1] - prices[i]
return result
55. 跳跃游戏
class Solution:
def canJump(self, nums: List[int]) -> bool:
if len(nums) == 1:
return True
cover = 0
i = 0
while i <= cover:
cover = max(nums[i]+i, cover)
if cover >= len(nums)-1:
return True
i += 1
return False
45.跳跃游戏II
标签:return,游戏,int,II,prices,算法,跳跃 From: https://www.cnblogs.com/miramira/p/18148335