Python DP Best Solution O(n), Understandable logic with simple explanation
\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n\t""" Check for 3 scenarios, \n\tCase 1 - If number if zero (n==0) then return pos, neg as 
```\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n\t""" Check for 3 scenarios, \n\tCase 1 - If number if zero (n==0) then return pos, neg as zero.\n\tCase 2 - If number is greaer than zero(n>0) then  pos length should be +1 and if there is neg then neg will be +1 becase ( neg * pos == neg) so it increase by 1\n\tCase 3 - If number is less than zero (n<0) then pos will be 1+neg (because neg * neg == pos) and neg will be 1 + pos (beacuse neg*pos == neg)\n\t"""\n            pos = neg = ans = 0\n    \n            for n in nums:\n                if n > 0:\n                    pos = 1 + pos\n                    neg = 1 + neg if neg else 0\n                elif n <0:\n                    pos, neg = 1 + neg if neg else 0, 1 + pos\n                else:\n                    pos, neg = 0,0\n                ans = max(ans, pos)\n\n            return ans\n\n```
['Array', 'Dynamic Programming', 'Python']