Simple Java 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:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    public int maxNonDecreasingLength(int[] nums1, int[] nums2) {\n        int n = nums1.length;\n        int count1[] = new int[n];\n        int count2[] = new int[n];\n        count1[n-1]=1;\n        count2[n-1]=1;\n        int max = 1;\n        for(int i=n-2;i>=0;i--) {\n            count1[i] = 1;\n            count2[i] = 1;\n            if(nums1[i]<=nums1[i+1]){\n                count1[i]=count1[i+1]+1;\n            }\n            if(nums1[i]<=nums2[i+1]){\n                count1[i]=Math.max(count2[i+1]+1, count1[i]);\n            }\n\n            if(nums2[i]<=nums1[i+1]){\n                count2[i]=count1[i+1]+1;\n            }\n            if(nums2[i]<=nums2[i+1]){\n                count2[i]=Math.max(count2[i+1]+1, count2[i]);\n            }\n            //System.out.println(count1[i]+" "+count2[i]);\n            max = Math.max(max, Math.max(count1[i],count2[i]));\n        }\n\n        return max;\n    }\n}\n```
['Java']