C++ SOLUTION USING 2 ARRAYS
Code\n\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size();\n        int maxi=1;\n 
# Code\n```\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size();\n        int maxi=1;\n        vector<int> vec1(n,1),vec2(n,1);\n        for(int i=1;i<n;i++){\n            if(nums1[i]>=nums1[i-1]) vec1[i]=vec1[i-1]+1;\n            if(nums2[i]>=nums2[i-1]) vec2[i]=vec2[i-1]+1;\n            if(nums1[i]>=nums2[i-1]) vec1[i]=max(vec1[i],vec2[i-1]+1);\n            if(nums2[i]>=nums1[i-1]) vec2[i]=max(vec2[i],vec1[i-1]+1);\n            maxi=max(maxi,max(vec1[i],vec2[i]));\n        }\n        return maxi;\n    }\n};\n```
['C++']