dp python
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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python []\nclass Solution(object):\n    def maxNonDecreasingLength(self, nums1, nums2):\n        """\n        :type nums1: List[int]\n        :type nums2: List[int]\n        :rtype: int\n        """\n        dp = [[0,0] for _ in range(len(nums1))]\n        \n\n        length = 0\n\n        for i in range(len(nums1)):\n            dp[i][0] = dp[i][1] = 1\n            if i > 0:\n                if nums1[i] >= nums1[i-1]:\n                    dp[i][0] = dp[i-1][0]+1\n                if nums1[i] >= nums2[i-1]:\n                    dp[i][0] = max(dp[i][0],dp[i-1][1] + 1)\n                if nums2[i] >= nums2[i-1] :\n                    dp[i][1] = dp[i-1][1] + 1\n                if nums2[i] >= nums1[i-1]:\n                    dp[i][1] = max(dp[i][1],dp[i-1][0] + 1)\n            length = max(length,max(dp[i][0],dp[i][1]))\n   \n        return length\n\n\n\n        \n\n        \n```
['Python']