O(1) python3 solution
Intuition\nThis question is a perfect example of trying to record down the min / max along individual path, preserving the original structure of using a 2 times
# Intuition\nThis question is a perfect example of trying to record down the min / max along individual path, preserving the original structure of using a 2 times N matrix, where N is the length of nums 1 or nums 2.\n\n# Approach\nIterate through dimension N, record down the maximum path to reach position i in nums1 or nums2. \n\n# Complexity\n- Time complexity: O(N)\n\n- Space complexity: O(1)\n\n# Code\n```python3 []\nclass Solution:\n    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:\n\n        maxLenNums1 = 1\n        maxLenNums2 = 1\n        res = 1\n        for i in range(1,len(nums1)):\n            num1sum = maxLenNums1\n            num2sum = maxLenNums2\n            # compute maxLenNums1\n            if (nums1[i] >= nums1[i - 1]) & (nums1[i] >= nums2[i - 1]):\n                maxLenNums1 = max(maxLenNums1+1,maxLenNums2+1)\n            elif (nums1[i] >= nums1[i - 1]):\n                maxLenNums1 = maxLenNums1+1\n            elif (nums1[i] >= nums2[i - 1]):\n                maxLenNums1 = maxLenNums2+1\n            else:\n                maxLenNums1 = 1\n\n            # compute maxLenNums2\n            if (nums2[i] >= nums1[i - 1]) & (nums2[i] >= nums2[i - 1]):\n                maxLenNums2 = max(num1sum+1,num2sum+1)\n            elif (nums2[i] >= nums1[i - 1]):\n                maxLenNums2 = num1sum+1\n            elif (nums2[i] >= nums2[i - 1]):\n                maxLenNums2 = num2sum+1\n            else:\n                maxLenNums2 = 1\n\n            res = max(maxLenNums2, max(maxLenNums1,res))\n        return res\n\n\n```
['Python3']