Python One Pass, Constant Space Solution
Beat 100% on runtime and 99% on space for Python.\n\n\nclass Solution:\n    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:\n      
Beat 100% on runtime and 99% on space for Python.\n\n```\nclass Solution:\n    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:\n        """\n        Keep track of two lengths and latest numbers.\n        \n        First one is the greedy (current longest one), second one is the backup.\n        \n        If at any point the first list uses the smallest of num1 and num2, backup resets because if that index is used, then it might as well have used greedy.\n        \n        When greedy reaches a wall (larger than both numbers), backup becomes greedy, and new backup starts at that index.\n        \n        Continuously update maxLen based on current length of greedy.\n        """\n        \n        maxLen = 0\n        len1, len2 = 0, 0\n        num1, num2 = 0, 0\n        \n        \n        for i in range(len(nums1)):\n            smaller, larger = nums1[i], nums2[i]\n    \n            if smaller > larger:\n                smaller, larger = larger, smaller\n            \n            if num1 <= smaller:\n                num1 = smaller\n                len1 += 1\n                maxLen = max(maxLen, len1)\n                num2 = 0\n                len2 = 0\n            elif num1 <= larger:\n                num1 = larger\n                len1 += 1\n                maxLen = max(maxLen, len1)\n                if num2 <= smaller:\n                    len2 += 1\n                else:\n                    len2 = 1\n                num2 = smaller\n            \n            # num1 hit a wall\n            elif num2 <= smaller:\n                num1 = smaller\n                len1 = len2 + 1\n                num2 = 0\n                len2 = 0\n            elif num2 <= larger:\n                num1 = larger\n                len1 = len2 + 1\n                num2 = smaller\n                len2 = 1\n            \n            # num2 hit a wall also\n            else:\n                num1 = smaller\n                len1 = 1\n                num2 = 0\n                len2 = 0\n        return maxLen\n```
['Python']