C++ Easy Solution || DP
class Solution {\npublic:\n    int getMaxLen(vector<int>& nums) {\n        int p =0;  // counter for positive number\n        int n =0;  // counter for positive
``` class Solution {\npublic:\n    int getMaxLen(vector<int>& nums) {\n        int p =0;  // counter for positive number\n        int n =0;  // counter for positive number\n        int fn =0;  // first negative number\n        int res = 0;\n        for(int i=0;i<nums.size();i++){\n            if(nums[i]==0){\n                p =0;\n                n=0;\n                fn = -1;\n            }\n            else if(nums[i]>0){\n                p++;\n            }\n            else{\n                n++;\n                if(n==1) fn=i;\n            }\n            \n            if(n%2==0){  // even number of negative number makes , positive\n                res = max(res , n+p);\n            }\n            else{ \n                res = max(res , i-fn);\n            }\n        }\n        return res;\n    }\n}; ```
[]