cpp O(1)
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```\nclass Solution {\npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        int prevCount1 = 1, prevCount2 = 1;\n        int maxLen = 1;\n\n        for (int i = 1; i < nums1.size(); i++) {\n            int currCount1 = 1, currCount2 = 1;\n            \n            if (nums1[i] >= nums1[i - 1]) {\n                currCount1 = max(currCount1, prevCount1 + 1);\n            }\n            if (nums1[i] >= nums2[i - 1]) {\n                currCount1 = max(currCount1, prevCount2 + 1);\n            }\n            if (nums2[i] >= nums2[i - 1]) {\n                currCount2 = max(currCount2, prevCount2 + 1);\n            }\n            if (nums2[i] >= nums1[i - 1]) {\n                currCount2 = max(currCount2, prevCount1 + 1);\n            }\n            \n            maxLen = max(maxLen, max(currCount1, currCount2));\n            prevCount1 = currCount1;\n            prevCount2 = currCount2;\n        }\n        \n        return maxLen;\n    }\n};\n\n```
['C++']