C++, BEST EXPLANATION
neg = the number of negative numbers so far\nfirstNef = the index of the first negative number\nzero = the index of the last 0 value\n\nalgorithm\nwe have to ke
neg = the number of negative numbers so far\nfirstNef = the index of the first negative number\nzero = the index of the last 0 value\n\n**algorithm**\nwe have to keep track of the number of negative values; (neg)\nif neg % 2 == 0 (even): then the product of all the number from the last zero index to current index is positive, the length is **i - zero**\nif neg % 2 == 1 (odd): then the product of all the number from the last zero index to current index is negative, so we exclude the first negative number and count only the number from **firstNeg to current index -> i - firstNeg**\n\n\n```\nclass Solution {\npublic:\n\n    int getMaxLen(vector<int>& nums) {\n        int ans = 0;\n        int a, n;\n        n = nums.size();\n        \n        if(n == 1)\n            return nums[0] > 0;\n        \n        int neg = 0;\n        int firstNeg = -1;\n        int zero = -1;\n        \n        for(int i=0; i<n; i++) {\n            a = nums[i];\n            if(a == 0) {\n                neg = 0;\n                firstNeg = -1;\n                zero = i;\n                continue;\n            }\n            if(a < 0) {\n                if(firstNeg == -1) {\n                    firstNeg = i;\n                }\n                neg++;\n            }\n            if(neg % 2 == 0) {\n                ans = max(ans, i - zero);\n            } else {\n                ans = max(ans, i - firstNeg);\n            }\n        }\n        return ans;\n    }\n    \n};\n```
['Dynamic Programming', 'C']