#
#
# @param prices int整型一维数组
# @return int整型
#
class Solution:
def maxProfit(self , prices ):
# write code here
profit = 0
hold = 0
flag = 0
for i in range(len(prices)-1):
if prices[i] < prices[i+1] and not flag:
flag = 1
hold = prices[i]
if prices[i] > prices[i+1] and flag:
flag = 0
profit += prices[i] - hold
if flag:
profit += prices[len(prices)-1] - hold
return profit