Skip to content

Instantly share code, notes, and snippets.

@amraks
Created February 21, 2019 02:18
Show Gist options
  • Save amraks/fcbbdf16749aede349caa50fa2a6840f to your computer and use it in GitHub Desktop.
Save amraks/fcbbdf16749aede349caa50fa2a6840f to your computer and use it in GitHub Desktop.
class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
if not prices:
return 0
s = 0
for i in range(1, len(prices)):
if prices[i] - prices[i-1] > 0:
s = s + prices[i] - prices[i-1]
#print(s)
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment