Sliding window solution (c++)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int getMaxLen(vector<int>& nums) {\n        int i=0;\n        int j=0;\n        int n=nums.size();\n      long long  int prod=1;\n        int ans=0;\n        while(j<n){\n           prod*=nums[j];\n           if(prod>0){\n               prod=1;\n               ans=max(ans,j-i+1);\n           }\n           else if(prod==0){\n               i=j+1;\n               prod=1;\n           }\n           else \n           prod=-1;\n           \n           j++;\n        \n\n        }\n       reverse(nums.begin(),nums.end());\n         i=0;\n         j=0;\n         prod=1;\n        int res=0;\n        while(j<n){\n           prod*=nums[j];\n           if(prod>0){\n               res=max(res,j-i+1);\n               prod=1;\n           }\n           else if(prod==0){\n               i=j+1;\n               prod=1;\n           }\n           else\n           prod=-1;\n           \n           j++;\n        \n\n        }\n        cout<<res<<endl;\n        ans=max(ans,res);\n        \n        return ans;\n\n    }\n};\n```
['C++']