Python3 O(n) time O(1) space
curLenPos records the maximum length of subarray with positive product that ends with the current element. \nand curlenNeg records the maximum length of subarra
*curLenPos* records the maximum length of subarray with positive product that ends with the current element. \nand *curlenNeg* records the maximum length of subarray with negative produc that ends withe the current element.\n```\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n        curLenPos = 0\n        curLenNeg = 0\n        ans = 0\n        for num in nums:\n            if num > 0:\n                curLenPos,curLenNeg = curLenPos + 1, curLenNeg + 1 if curLenNeg != 0 else 0\n            elif num < 0:\n                curLenNeg,curLenPos = curLenPos + 1, curLenNeg + 1 if curLenNeg != 0 else 0\n            else:\n                curLenNeg = 0\n                curLenPos = 0\n            ans = max(ans,curLenPos)\n            \n        return ans\n            \n```
['Dynamic Programming', 'Python3']