Python DP Solution (with intuitive comments)
\nclass Solution(object):\n    def getMaxLen(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: int\n        """\n        \n        n = l
```\nclass Solution(object):\n    def getMaxLen(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: int\n        """\n        \n        n = len(nums)\n        pos = [0] * n # (1)\n        neg = [0] * n # (2)\n        \n        pos[0] = 1 if nums[0] > 0 else 0\n        neg[0] = 1 if nums[0] < 0 else 0\n        \n        for i in range(1, n):\n            if nums[i] < 0:\n                pos[i] = 1 + neg[i - 1] if neg[i - 1] else 0\n                neg[i] = 1 + pos[i - 1] if pos[i - 1] else 1\n            elif nums[i] > 0:\n                pos[i] = 1 + pos[i - 1] if pos[i - 1] else 1\n                neg[i] = 1 + neg[i - 1] if neg[i - 1] else 0\n                    \n        return max(pos)\n    \n    # The idea is to keep track of the maximum length of subarray with negative product and maximum length of subarray with positive product, because depending on the sign of each number we encounter, we want to use each length to inform the other.\n    # (1) pos[i] = maximum subarray length with positive product including nums[i] so far\n    # (2) neg[i] = maximum subarray length with negative product including nums[i] so far\n    # Here are the different possible cases:\n    #   - If the number is negative:\n    \n    #       - If there is a non-empty subarray with negative product to the immediate left of this number:\n    #           - Add this number to the subarray with positive product, since negative times negative equals positive.\n    #       - Otherwise:\n    #           - No subarray with positive product at this point.\n    \n    #       - If there is a non-empty subarray with positive product to the immediate left of this number:\n    #           - Add this number to subarray with negative product, since positive times negative equals negative.\n    #       - Otherwise:\n    #           - Begin a new subarray with negative product, since a single negative value has a negative product.\n    \n    #   - If the number is positive:\n    \n    #       - If there is a non-empty subarray with positive product to the immediate left of this number:\n    #           - Add this number to the subarray with positive product, since positive times positive equals positive.\n    #       - Otherwise:\n    #           - Begin a new subarray with positive product, since a single positive value has a positive product.\n    \n    #       - If there is a non-empty subarray with negative product to the immediate left of this number:\n    #           - Add this number to subarray with negative product, since negative times positive equals negative.\n    #       - Otherwise:\n    #           - No array with negative product at this point.\n```
['Dynamic Programming', 'Python']