LeetCode 122 Best Time to Buy and Sell Stock II

LeetCode 122 Best Time to Buy and Sell Stock II Problem

Download Code
class Solution(object):
    def maxProfit(self, prices):
        """
        :type prices: List[int]
        :rtype: int
        """
        # sum of prices[i + 1] - prices[i], if prices[i + 1] > prices[i]
        return sum([y - x for x, y in zip(prices[0:-1], prices[1:]) if x < y])
Download Best Time to Buy and Sell Stock II.py

List of all Best Time to Buy and Sell Stock II problems

Leetcode 122 Best Time to Buy and Sell Stock II problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.

Feedback is the most important part of any website.

If you have any query, suggestion or feedback, Please feel free to contact us.