✔️[C++] || Self Explained Simple Code || Easy to Understand || TC: O( n ) , SC: O( 1 )
Please Upvote if it helps\u2B06\uFE0F\n\n\tint getMaxLen(vector<int>& nums) {\n        int n=nums.size(),mx=0, last_index=0,last_neg_index=-1,neg=0;\n        fo
#### *Please Upvote if it helps\u2B06\uFE0F*\n```\n\tint getMaxLen(vector<int>& nums) {\n        int n=nums.size(),mx=0, last_index=0,last_neg_index=-1,neg=0;\n        for(int i=0;i<n;++i){\n            if(nums[i]==0) last_index=i+1,last_neg_index=-1,neg=0;\n            else if(nums[i]<0){\n                if(last_neg_index==-1) last_neg_index=i;\n                neg++;\n            }\n            else if(nums[i]>0 && neg%2) mx=max(mx,i-last_neg_index);\n            if(neg%2==0) mx=max(mx,i-last_index+1);\n        }\n        return mx;\n    }\n```
['Greedy', 'C']