#NEWLINE# def maxProfit( self , prices ) : #NEWLINE# #INDENT# '\n        multiple transactions\n        you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).\n\n        Algorithm: transformed array\n\n        :param prices: list of integers\n        :return: integer\n        ' #NEWLINE# if ( len ( prices ) <= 1 ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# delta_prices = [ ] #NEWLINE# for i in xrange ( 1 , len ( prices ) ) : #NEWLINE# #INDENT# delta_prices . append ( ( prices [ i ] - prices [ ( i - 1 ) ] ) ) #NEWLINE# #UNINDENT# profit = 0 #NEWLINE# for i in xrange ( len ( delta_prices ) ) : #NEWLINE# #INDENT# if ( delta_prices [ i ] > 0 ) : #NEWLINE# #INDENT# profit += delta_prices [ i ] #NEWLINE# #UNINDENT# #UNINDENT# return profit