java, dp, o(n) time + o(n) space, concise code with comments
\npublic int getMaxLen2(int[] nums) {\n        int len = nums.length, max = 0;\n        int[] fneg = new int[len+1]; // the length of longest negative product s
```\npublic int getMaxLen2(int[] nums) {\n        int len = nums.length, max = 0;\n        int[] fneg = new int[len+1]; // the length of longest negative product sub-array \n        int[] fpos = new int[len+1]; // the length of longest positive product sub-array \n\n        for(int i=1; i<=len; i++){\n            if(nums[i-1] > 0){\n\t\t\t// when positive subarray meets a positive number, the length will be increased by one at all case\n\t\t\t// the negative subarray will be increased only if it is not empty. \n                fpos[i] = fpos[i-1] + 1;\n                fneg[i] = fneg[i-1] > 0 ? fneg[i-1] + 1 : 0;\n            }else if(nums[i-1] < 0){\n\t\t\t// the positive subarray will be increased only if the previous product is negative\n\t\t\t// the negative subarray will be increased only if the previous product is positive\n                fpos[i] = fneg[i-1] > 0 ? fneg[i-1] + 1 : 0;\n                fneg[i] = fpos[i-1] + 1;\n            }\n            max = Math.max(fpos[i], max);\n        }\n        return max;\n    }\n\t```
['Dynamic Programming', 'Java']