Simple python3 solutions | O(1) memory
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n``` python3 []\nclass Solution:\n    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:\n        prev_elems = (0, 0)\n        prev_lengths = [0, 0]\n        \n        result = 0\n\n        for elems in zip(nums1, nums2):\n            current_lengths = [1, 1]\n            for i, elem in enumerate(elems):\n                for j, prev_elem in enumerate(prev_elems):\n                    if elem >= prev_elem:\n                        current_lengths[i] = max(current_lengths[i], prev_lengths[j] + 1)\n            \n            result = max(result, max(current_lengths))\n\n            prev_elems = elems\n            prev_lengths = current_lengths\n        \n        return result\n```\n``` python3 []\n# simpler solution without inner loops\n\nclass Solution:\n    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:\n        prev_elems = (0, 0)\n        prev_lengths = [0, 0]\n        \n        result = 0\n\n        for a, b in zip(nums1, nums2):\n            current_lengths = [1, 1]\n            if a >= prev_elems[0]:\n                current_lengths[0] = max(current_lengths[0], prev_lengths[0] + 1)\n            if a >= prev_elems[1]:\n                current_lengths[0] = max(current_lengths[0], prev_lengths[1] + 1)\n            if b >= prev_elems[0]:\n                current_lengths[1] = max(current_lengths[1], prev_lengths[0] + 1)\n            if b >= prev_elems[1]:\n                current_lengths[1] = max(current_lengths[1], prev_lengths[1] + 1)\n            \n            result = max(result, max(current_lengths))\n\n            prev_elems = (a, b)\n            prev_lengths = current_lengths\n        \n        return result\n\n```
['Dynamic Programming', 'Greedy', 'Python3']