Module Expr Str Assign NameStore Str ClassDef bases body FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If CompareGtE NameLoad NameLoad body Return Call AttributeLoad NameLoad attr NameLoad Assign NameStore ListComp Num comprehension NameStore Call NameLoad BinOpAdd NameLoad Num Assign NameStore ListComp Num comprehension NameStore Call NameLoad BinOpAdd NameLoad Num Assign NameStore Num For NameStore Call NameLoad Num NameLoad body Assign NameStore BinOpSub SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index BinOpSub NameLoad Num For NameStore Call NameLoad NameLoad Num Num body Assign SubscriptStore NameLoad Index NameLoad Call NameLoad BinOpAdd SubscriptLoad NameLoad Index BinOpSub NameLoad Num NameLoad BinOpAdd SubscriptLoad NameLoad Index NameLoad NameLoad Assign SubscriptStore NameLoad Index NameLoad Call NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad Assign NameStore Call NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Num For NameStore Call NameLoad Num Call NameLoad NameLoad body AugAssignAdd NameStore Call NameLoad Num BinOpSub SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index BinOpSub NameLoad Num Return NameLoad decorator_list decorator_list If CompareEq NameLoad Str body Print Call AttributeLoad Call NameLoad attr Num ListLoad Num Num Num
N/A N/A 
Say you have an array for which the ith element is the price of a given stock on day i.

Design an algorithm to find the maximum profit. You may complete at most k transactions.

Note:
You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
 N/A __author__ Daniel Solution N/A N/A maxProfit N/A N/A self k prices N/A N/A N/A 
        DP
        local_{i,j} = \max(global_{i-1.j-1}+\Delta, local_{i-1,j}+\Delta)

        global_{i,j} = \max(local_{i, j}, global_{i-1,j})
        :type k: int
        :type prices: List[int]
        :rtype: int
         N/A n N/A len prices N/A N/A k n N/A N/A N/A N/A self maxProfit_unlimited_transactions prices N/A l N/A 0 N/A _ N/A xrange N/A k 1 N/A g N/A 0 N/A _ N/A xrange N/A k 1 N/A gmax 0 N/A i N/A xrange 1 n N/A N/A diff N/A N/A prices N/A i N/A prices N/A N/A i 1 N/A j N/A xrange k 0 -1 N/A N/A N/A l N/A j N/A max N/A N/A g N/A N/A j 1 diff N/A N/A l N/A j diff N/A N/A g N/A j N/A max N/A l N/A j N/A g N/A j N/A gmax N/A max gmax N/A g N/A j N/A gmax N/A maxProfit_unlimited_transactions N/A N/A self prices N/A N/A N/A profit 0 N/A i N/A xrange 1 N/A len prices N/A N/A profit N/A max 0 N/A N/A prices N/A i N/A prices N/A N/A i 1 N/A profit N/A N/A N/A N/A __name__ __main__ N/A N/A N/A N/A N/A Solution maxProfit 2 N/A 1 2 4