human
I am working on the file "Python/leetcode/easy/strings-arrays.ipynb".
The first task is:
Q.5. Say you have an array prices 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 as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).
Note: You may not engage in multiple transactions at the same time (i.e., you must sell the stock before you buy again).
Can you write Python code for it?
assistant
#Here is Python code to find the maximum profit.

class Solution(object):
    def maxProfit(self, prices: List[int]) -> int:
        """
        :type prices: List[int]
        :rtype: int
        
        Maximum Profit is the cumulation of all positive differences.
        """
        profit = 0
        for i in range(1, len(prices)):
            diff = prices[i] - prices[i-1]
            if diff > 0:
                profit += diff
        
        return profit

print(Solution().maxProfit([7,6,4,3,1]))