Python 10 line solution
Let P_i and N_i be the longest positive and negative products starting at i, respectively.  We can establish a recursive formula for these variables.  If the le
Let P_i and N_i be the longest positive and negative products starting at i, respectively.  We can establish a recursive formula for these variables.  If the length of the `nums` array is n, then P_n = N_n = 0 as a base case (there is no sequence after the end of the array).\n\nThen, if `nums[i] > 0` then P_i = 1 + P_{i + 1} since we can add one more positive number and the remaining product will remain positive.  Similarly, as long as N_{i + 1} > 0 (i.e., there is a negative product of non-zero length after the current index) then `N_i = 1 + N_{i + 1}`.  This is the `if n > 0` statement in the code below.\n\nIf `nums[i] < 0` the reasoning is similar -- we can make the positive sequence negative, so N_i = 1 + P_i, and as long as there is a non-zero length negative product, we can make it positive, so P_i = 1 + N_{i + 1}.\n\nIf `nums[i] = 0` then the maximum length positive or negative sequences beginning at `i` are necessarily zero.\n\n```\nclass Solution:\n    def getMaxLen(self, nums: List[int]) -> int:\n        max_P, P, N = 0, 0, 0\n        for n in reversed(nums):\n            if n > 0:\n                P, N = 1 + P, (1 + N if N > 0 else 0)\n            elif n < 0:\n                P, N = (1 + N if N > 0 else 0), 1 + P\n            else:\n                P, N = 0, 0\n            max_P = max(max_P, P)\n        return max_P\n```
['Dynamic Programming', 'Recursion', 'Python']