Answers for "max product subarray leetcode"

C++
1

max product subarray leetcode

Input: [2,3,-2,4]
Output: 6
Explanation: [2,3] has the largest product 6.
Posted by: Guest on December-13-2020
1

maximum subarray solution leetcode

def approach3(nums):
    ans = nums[0]
    subarr_sum = nums[0]

    for i in range(1, len(nums)):
        subarr_sum = max(nums[i], nums[i] + subarr_sum)
        ans = max(ans, subarr_sum)

    return ans
Posted by: Guest on August-24-2020

Browse Popular Code Answers by Language