Simple cpp solution
Code\ncpp []\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        int n = nums1.size();\n        vector
# Code\n```cpp []\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        int n = nums1.size();\n        vector<int> dp1(n, 1), dp2(n, 1);\n        \n        int result = 1;\n        \n        for (int i = 1; i < n; ++i) {\n            if (nums1[i] >= nums1[i - 1]) {\n                dp1[i] = dp1[i - 1] + 1;\n            }\n            if (nums1[i] >= nums2[i - 1]) {\n                dp1[i] = max(dp1[i], dp2[i - 1] + 1);\n            }\n            \n            if (nums2[i] >= nums1[i - 1]) {\n                dp2[i] = dp1[i - 1] + 1;\n            }\n            if (nums2[i] >= nums2[i - 1]) {\n                dp2[i] = max(dp2[i], dp2[i - 1] + 1);\n            }\n            \n            result = max({result, dp1[i], dp2[i]});\n        }\n        \n        return result;\n    }\n};\n\n```
['C++']