-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
Bug Report for https://neetcode.io/problems/maximum-product-subarray
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
[-1,-2,-3,0] check for this array, my solution fails for this, still it is accepted on Neetcode, same code fails on Leetcode
this was my code
class Solution:
def maxProduct(self, nums: List[int]) -> int:
maxi = nums[0]
curr = nums[0]
for i in range(1, len(nums)):
curr = curr*nums[i]
maxi = max(curr, maxi)
if curr == 0:
curr=1
curr = nums[-1]
maxi = max(curr, maxi)
for i in range(len(nums)-2, -1, -1):
curr = curr*nums[i]
maxi = max(curr, maxi)
if curr == 0:
curr=1
return maxi

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels