Python Greedy - O(n) Time, O(1) Space - 95.29% Faster
Python Greedy approach, not using dp:\n\n```python\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n        ans = 0\n        pos = 0\n       
Python Greedy approach, not using dp:\n\n```python\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n        ans = 0\n        pos = 0\n        neg = 0\n        \n        for n in nums:\n            if n > 0:\n                pos += 1\n                neg = 1 + neg if neg else 0\n            elif n < 0:\n                tmp = pos\n                pos = 1 + neg if neg else 0\n                neg = 1 + tmp\n            else:\n                pos = 0\n                neg = 0\n            ans = max(ans, pos)\n        return ans
['Greedy', 'Python']