C++ || Single pass solution || T.C : O(N) || SC : O(1)  || Simple code
```\nclass Solution {\npublic:\n    int getMaxLen(vector& nums) {\n        \n        int len = nums.size();\n        int first_neg = -1, max_len = 0, curr_len =
```\nclass Solution {\npublic:\n    int getMaxLen(vector<int>& nums) {\n        \n        int len = nums.size();\n        int first_neg = -1, max_len = 0, curr_len = 0, neg_count = 0;\n        \n        for(int i = 0; i < len; i++)\n        {\n            if(nums[i] == 0)\n            {\n                curr_len = 0;\n                first_neg = -1;\n                neg_count = 0;\n                continue;\n            }\n            curr_len++;\n            \n            if(nums[i] < 0)\n            {\n                neg_count++;\n                if(first_neg == -1)\n                    first_neg = curr_len;\n            }\n            if(neg_count % 2 == 1)\n                max_len = max(max_len, curr_len - first_neg);\n            else\n                max_len = max(curr_len, max_len);\n        }\n\n        return max_len;\n    }\n};
[]