Skip to content

Instantly share code, notes, and snippets.

@munguial
Last active April 5, 2020 21:40
Show Gist options
  • Save munguial/7ba713fdf69a83bdb765aaa27497c67c to your computer and use it in GitHub Desktop.
Save munguial/7ba713fdf69a83bdb765aaa27497c67c to your computer and use it in GitHub Desktop.
Day 5 - Best time to buy and sell stock II
# https://leetcode.com/explore/featured/card/30-day-leetcoding-challenge/528/week-1/3287/
class Solution:
def maxProfit(self, prices: List[int]) -> int:
profit = 0
for i in range(1, len(prices)):
if prices[i] > prices[i- 1]:
profit += prices[i] - prices[i - 1]
return profit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment