No Kadanes Algo simple DP
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nsee solution\n https://youtu.be/vfZ34E7k7MI?feature=shared\n\n# Complexit
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nsee solution\n https://youtu.be/vfZ34E7k7MI?feature=shared\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```\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        \n        vector<int> dp1(nums1.size(),1);\n        vector<int> dp2(nums2.size(),1);\n        \n        for(int i=1;i<nums1.size();i++){\n            if(nums1[i]>=nums1[i-1]){\n                dp1[i]=max(dp1[i],dp1[i-1]+1);\n            }\n            if(nums1[i]>=nums2[i-1]){\n                dp1[i]=max(dp1[i],dp2[i-1]+1);\n            }\n            if(nums2[i]>=nums2[i-1]){\n                dp2[i]=max(dp2[i],dp2[i-1]+1);\n            }\n            if(nums2[i]>=nums1[i-1]){\n                dp2[i]=max(dp2[i],dp1[i-1]+1);\n            }\n        }\n        \n        return max(*max_element(dp1.begin(),dp1.end()),*max_element(dp2.begin(),dp2.end()));\n    }\n};\n```
['C++']