C++ || O(n) Time || O(1) Space || Step-By-Step Explanation
\nint getMaxLen(vector<int>& nums) {\n        int n=nums.size();\n        int pos=0;   //Length of subarray with max sum\n        int neg=0;   //Length of subar
```\nint getMaxLen(vector<int>& nums) {\n        int n=nums.size();\n        int pos=0;   //Length of subarray with max sum\n        int neg=0;   //Length of subarray with min sum\n        int ans=0;\n        for(int i=0;i<n;i++)\n        {\n            if(nums[i]==0)\n            {\n                //if number is zero the length of req subarray whill be zero\n                pos=0;\n                neg=0;\n            }\n            else if(nums[i]>0)\n            {\n                //if nums[i] is +ve the length of positibe subarray will increase by 1\n                //in case of neg string if it is zero it will remain zero otherwise it will also increase by 1\n                pos+=1;\n                if(neg!=0) neg+=1;\n            }\n            else\n            {\n                //if nums[i] is negative the length of both string will swap\n                //if neg subarray length was zero the new pos subarray will also have length zero \n                int temp=neg;\n                neg=pos+1;\n                if(temp==0) pos=0;\n                else pos=temp+1;\n            }\n            ans=max(ans,pos);\n        }\n        return ans;\n        \n    }\n```
['Dynamic Programming', 'C', 'C++']