C++ DP Bottom-Up Tabulation
\nclass Solution {\npublic:\n    int getMaxLen(vector<int>& nums) {\n        vector<int> dppos(nums.size(), 0);\n      \tvector<int> dpneg(nums.size(), 0);\n   
```\nclass Solution {\npublic:\n    int getMaxLen(vector<int>& nums) {\n        vector<int> dppos(nums.size(), 0);\n      \tvector<int> dpneg(nums.size(), 0);\n        \n        if (nums[0] > 0) dppos[0] = 1;\n            else if (nums[0] < 0) dpneg[0] = 1;\n\n        for (int i = 1; i < nums.size(); i++) {\n                if (nums[i] > 0) {\n                    dppos[i] = dppos[i-1] + 1;\n                    dpneg[i] = dpneg[i-1] > 0 ? dpneg[i-1]+1 : 0;\n                } else if (nums[i] < 0) {\n                    dppos[i] = dpneg[i-1] > 0 ? dpneg[i-1]+1 : 0;\n                    dpneg[i] = dppos[i-1] + 1;\n                } else {\n                    dppos[i] = dpneg[i] = 0;\n                }\n        }\n\n        int res = 0;\n            for (int i = 0; i < nums.size(); i++)\n                res = max(res, dppos[i]);\n        return res;\n    }\n};\nif Helpful Please Like and Upvoke\n```
['Dynamic Programming']