c++ solution
\nclass Solution {\npublic:\n    int dp[100005][3];\n    int find(vector<int>&nums1,vector<int>&nums2,int index,int lastType=-1){\n        if(index>=nums1.size(
```\nclass Solution {\npublic:\n    int dp[100005][3];\n    int find(vector<int>&nums1,vector<int>&nums2,int index,int lastType=-1){\n        if(index>=nums1.size()) return 0;\n        int ans=0;\n        if(dp[index][lastType+1]!=-1) return dp[index][lastType+1];\n        if(lastType==-1){\n            ans=max(ans,1+find(nums1,nums2,index+1,0));\n            ans=max(ans,1+find(nums1,nums2,index+1,1));\n            ans=max(ans,find(nums1,nums2,index+1,-1));\n        }\n        else{\n            int lastTypeElement=(lastType==0)?nums1[index-1]:nums2[index-1];\n            if(lastTypeElement<=nums1[index]){\n                ans=max(ans,1+find(nums1,nums2,index+1,0));\n            }\n            if(lastTypeElement<=nums2[index]){\n                ans=max(ans,1+find(nums1,nums2,index+1,1));\n            }\n        }\n        return dp[index][lastType+1] = ans;\n    }\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        memset(dp,-1,sizeof(dp));\n        return find(nums1,nums2,0);\n    }\n};\n```
['C', 'C++']