class Solution(object):
def wiggleMaxLength(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums)<2:
return len(nums)
up,down = 1,1
for i in range(1,len(nums)):
if nums[i] - nums[i-1] > 0:
up = down + 1
if nums[i] - nums[i-1] < 0:
down = up + 1
return max(up,down)
class Solution(object):
def maxProfit(self, prices, fee):
"""
:type prices: List[int]
:type fee: int
:rtype: int
"""
mi = prices[0]
n = len(prices)
res = 0
for i in range(1,n):
if prices[i] < mi:
mi = prices[i]
elif prices[i] > mi+fee:
res += prices[i]-mi-fee
mi = prices[i]-fee
return res