Java count even/odd negatives
Just note any subarray with even number of negatives and no zeros will produce a positve product;\ncount 0 as even;\n\n    public int getMaxLen(int[] nums) {\n 
Just note any subarray with even number of negatives and no zeros will produce a positve product;\ncount 0 as even;\n```\n    public int getMaxLen(int[] nums) {\n        int firstEvenNeg = -1, firstOddNeg = -2, res = 0, negCount = 0;  // treat 0 neg as even\n        for (int i = 0; i < nums.length; i++) {\n            if (nums[i] == 0) {  // reset everytime you met a zero;\n                negCount = 0; // neg count after last zero\n                firstEvenNeg = i;\n                firstOddNeg = -2;\n            } else {\n                if (nums[i] < 0) negCount++;  // number of negatives from last zero or head of array\n                if (negCount == 1 && firstOddNeg == -2) firstOddNeg = i;   // init odd cnt neg;\n                if (negCount % 2 == 0) res = Math.max(res, i - firstEvenNeg);  \n                else if (firstOddNeg > -2) res = Math.max(res, i - firstOddNeg);  \n            }\n        }\n        return res;\n    }\n```
[]