✅ C++ | Easy | DP
\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n    int n = nums1.size();\n    vector<int> dp1(n,1);\n   
```\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n    int n = nums1.size();\n    vector<int> dp1(n,1);\n    vector<int> dp2(n,1);\n    int maxLen = 1;\n    for (int i = 1; i < n; i++) {\n        for (int j = i-1; j < i; j++) {\n            if (nums1[i] >= nums1[j])\n                dp1[i] = max(dp1[i], dp1[j] + 1);\n            if (nums2[i] >= nums2[j])\n                dp2[i] = max(dp2[i], dp2[j] + 1);\n            if (nums1[i] >= nums2[j])\n                dp1[i] = max(dp1[i], dp2[j] + 1);\n            if (nums2[i] >= nums1[j])\n                dp2[i] = max(dp2[i], dp1[j] + 1);\n        }\n        maxLen=max(maxLen,max(dp1[i], dp2[i]));\n    }\n    return maxLen;    \n   }\n};\n```
['Dynamic Programming', 'C']