C++||DP|| Memoization || EASY ||2D-DP
Intuition\n Describe your first thoughts on how to solve this problem. \n2D-DP \n# Approach\n Describe your approach to solving the problem. \nWe just tried all
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n2D-DP \n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe just tried all possibility and calculated max value\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N*N)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N*N)\n# Code\n```\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        vector<vector<int>>dp(2,vector<int>(nums1.size(),1));\n        int i,ans=1;\n        for(i=1;i<nums1.size();i++)\n        {\n            if(nums1[i]>=nums1[i-1])\n            {\n                dp[0][i]=max(dp[0][i],1+dp[0][i-1]);\n            }\n             if(nums1[i]>=nums2[i-1])\n            {\n                dp[0][i]=max(dp[0][i],1+dp[1][i-1]);\n            }\n             if(nums2[i]>=nums1[i-1])\n            {\n                dp[1][i]=max(dp[1][i],1+dp[0][i-1]);\n            }\n             if(nums2[i]>=nums2[i-1])\n            {\n                dp[1][i]=max(dp[1][i],1+dp[1][i-1]);\n            }\n            ans=max(ans,max(dp[0][i],dp[1][i]));\n        }\n        return ans;\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C++']