Easy dp 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```\n/**\n * @param {number[]} nums1\n * @param {number[]} nums2\n * @return {number}\n */\nvar maxNonDecreasingLength = function(nums1, nums2) {\n  const N = nums1.length;\n  let dp0 = 1;\n  let dp1 = 1\n  let res = 1;\n  for (let i = 1; i < N; ++i) {\n    let v0 = 1;\n    let v1 = 1;\n    if (nums1[i] >= nums1[i - 1]) {\n      v0 = 1 + dp0;\n    }\n    if (nums1[i] >= nums2[i - 1]) {\n      v0 = Math.max(v0, dp1 + 1);\n    }\n\n    if (nums2[i] >= nums1[i - 1]) {\n      v1 = 1 + dp0;\n    }\n    if (nums2[i] >= nums2[i - 1]) {\n      v1 = Math.max(v1, 1 + dp1);\n    }\n    [dp0, dp1] = [v0, v1];\n    res = Math.max(res, dp0, dp1);\n  }\n  return res;\n};\n```
['JavaScript']