DP. Time O(n). Space O(1)
\nclass Solution:\n    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:\n        dp1, dp2, ans = 1, 1, 1\n        for (prev_n1, n1),
```\nclass Solution:\n    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:\n        dp1, dp2, ans = 1, 1, 1\n        for (prev_n1, n1), (prev_n2, n2) in zip(pairwise(nums1), pairwise(nums2)):\n            dp1, dp2 = (max(dp1 if n1 >= prev_n1 else 0, dp2 if n1 >= prev_n2 else 0) + 1, \n                        max(dp2 if n2 >= prev_n2 else 0, dp1 if n2 >= prev_n1 else 0) + 1)  \n            ans = max(dp1, dp2, ans)\n        return ans       \n```
['Dynamic Programming', 'Python3']