Java O(n) time O(1) space solution, beats 99.84%
Approach\nWe just need to keep the streak of negative and positive length from previous number, which can be stored in two variables (for better readability it 
# Approach\nWe just need to keep the streak of negative and positive length from previous number, which can be stored in two variables (for better readability it can be saved in 1d dp array, which increases space complexity to O(n)).\n\nWith these numbers we need to handle special case when num is zero - this resets streaks for positive and negative len both.\n\nThen we need to handle two cases:\n1. number is positive - if we have positive streak, just increment it, if we have negative streak, then we need to increment it too\n2. number is negative - we need to take current positive streak and increment it. If we do have a negative streak, we need to save it to the positive streak, because the minus switches it to positive product.\n\nNow we just need to find the maximal value that positive streak can reach and return it.\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\n    public int getMaxLen(int[] nums) {\n        var positiveLen = nums[0] > 0 ? 1 : 0;\n        var negativeLen = nums[0] < 0 ? 1 : 0;\n        var maxLen = positiveLen;\n\n        for (var i = 1; i < nums.length; i++) {\n            if (nums[i] == 0) {\n                positiveLen = 0;\n                negativeLen = 0;\n                continue;\n            }\n\n            final var nextNegative = negativeLen > 0 ? negativeLen + 1 : 0;\n\n            if (nums[i] > 0) {\n                positiveLen++;\n                negativeLen = nextNegative;\n            } else {\n                negativeLen = positiveLen + 1;\n                positiveLen = nextNegative;\n            }\n\n            maxLen = Math.max(maxLen, positiveLen);\n        }\n\n        return maxLen;\n    }\n}\n```
['Java']