Dynamic Programming
Time Complexity : O(N)\nSpace Complexity : O(1)\n```\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n        pos = neg = 0 \n        res = 0
**Time Complexity : O(N)**\n**Space Complexity : O(1)**\n```\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n        pos = neg = 0 \n        res = 0 \n        for num in nums: \n            if not num:\n                pos = neg = 0 \n            elif num > 0:\n                pos += 1 \n                if neg != 0:\n                    neg += 1 \n                res = max(res, pos)\n            else:\n                pos, neg = neg, pos \n                neg += 1 \n                if pos != 0: \n                    pos += 1 \n                res = max(res, pos)\n        return res
['Python']