Simple python solution | Time: O(N) | Space: O(1)
\ndef getMaxLen(self, nums: List[int]) -> int:\n        \n        n = len(nums)\n        last_neg_index= None\n        last_zero_index = -1\n        \n        a
```\ndef getMaxLen(self, nums: List[int]) -> int:\n        \n        n = len(nums)\n        last_neg_index= None\n        last_zero_index = -1\n        \n        ans = 0\n        cur_prod = 1\n        \n        for i in range(n):\n            \n            cur_prod *= nums[i]\n        \n            if cur_prod>0: ans = max(ans, i-last_zero_index)\n                \n            elif cur_prod<0:\n                \n                #check for previous neg_index\n                if last_neg_index != None:\n                    ans = max(ans, i-last_neg_index)\n                else:\n                    last_neg_index = i\n                    \n            else:\n                #zero\n                last_zero_index= i\n                \n                cur_prod = 1\n                last_neg_index = None\n                \n        return ans\n```
[]