Python One pass Solution w/o DP
The main approach is to store index of negative and positive product from where it started. We don\'t need to find the current product of array just the sign is
The main approach is to store index of negative and positive product from where it started. We don\'t need to find the current product of array just the sign is enough.\n\nOne you reach the curr_product is zero, just reset the positive and negative index from where it started.\n\n```\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n        neg=None\n        pos=-1\n        curr_product=1\n        max_len =0\n        \n        for i in range(0,len(nums)):\n            if curr_product>0:\n                if nums[i]>0:\n                    curr_product=1\n                elif nums[i]==0:\n                    curr_product=0\n                else:\n                    curr_product=-1\n            else:\n                if nums[i]>0:\n                    curr_product=-1\n                elif nums[i]==0:\n                    curr_product=0\n                else:\n                    curr_product=1\n                \n            if curr_product<0:\n                if neg is None:\n                    neg= i\n                else:\n                    max_len = max(max_len,i-neg)\n            elif curr_product>0:\n                max_len = max(max_len,i-pos)\n            else:\n                pos = i\n                curr_product = 1\n                neg = None\n        return max_len\n\t\t```
['Greedy']