Python - one simple iteration through the list
Once I understood Kadane\'s algorithm, I found the approach could be applied to a large range of other DP problems.\n\n\nclass Solution(object):\n    def getMax
Once I understood Kadane\'s algorithm, I found the approach could be applied to a large range of other DP problems.\n\n````\nclass Solution(object):\n    def getMaxLen(self, nums):\n        max_positive = 0\n        current_neg = 0\n        current_pos = 0\n\n        for n in nums:\n            if n < 0:\n                new_neg = current_pos + 1\n                new_pos = current_neg + 1 if current_neg else 0\n            elif n > 0:\n                new_neg = current_neg + 1 if current_neg else 0\n                new_pos = current_pos + 1\n            else:\n                new_neg, new_pos = 0, 0\n            current_neg, current_pos = new_neg, new_pos\n            max_positive = max(max_positive, current_pos)\n        return max_positive\n````
['Python']