O(n), O(1), Beets 100%. simple
\n# Code\n\npublic class Solution {\n    public int MaxNonDecreasingLength(int[] nums1, int[] nums2) {        \n        int a1 = 1;\n        int a2 = 1;\n      
\n# Code\n```\npublic class Solution {\n    public int MaxNonDecreasingLength(int[] nums1, int[] nums2) {        \n        int a1 = 1;\n        int a2 = 1;\n        int res = 1;\n        for (int i = 1; i < nums1.Length; i++)\n        {          \n            int b1 = a1;\n            int b2 = a2;  \n            a1 = Math.Max(\n                   nums1[i] >= nums1[i - 1] ? b1 : 0,\n                   nums1[i] >= nums2[i - 1] ? b2 : 0) + 1;\n            a2 = Math.Max(\n                   nums2[i] >= nums2[i - 1] ? b2 : 0,\n                   nums2[i] >= nums1[i - 1] ? b1 : 0) + 1;         \n            res = Math.Max(res, Math.Max(a1, a2));            \n        }\n        \n        return res;\n    }\n}\n```
['C#']