Simplest C++ Solution.
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        //here dp state is dp(i,j) i.e till size i with last elemtn in jth array\n        vector<vector<int>>dp(nums1.size()+1,vector<int>(2,1));\n        if(nums1.size()==1) return 1;\n        int ans=INT_MIN;\n        for(int i=2;i<dp.size();i++){\n            for(int j=0;j<2;j++){\n             if(j==0){\n                   if(nums1[i-2]<=nums1[i-1]) dp[i][j]=max(dp[i][j],dp[i-1][0]+1);\n                if(nums2[i-2]<=nums1[i-1]) dp[i][j]=max(dp[i][j],dp[i-1][1]+1);\n             }\n             else{\n                   if(nums1[i-2]<=nums2[i-1]) dp[i][j]=max(dp[i][j],dp[i-1][0]+1);\n                if(nums2[i-2]<=nums2[i-1]) dp[i][j]=max(dp[i][j],dp[i-1][1]+1);\n             }\n             ans=max(ans,dp[i][j]);\n\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']