Created
February 21, 2019 02:18
-
-
Save amraks/fcbbdf16749aede349caa50fa2a6840f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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