class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
if len(prices) <= 1:
return 0
sum = 0
for i in range(1,len(prices)):
if prices[i] > prices[i-1]:
sum += prices[i] - prices[i-1]
return sum
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/#/description
Say you have an array for which the ith element is the price of a given stock on day i.