Leetcode 2771. Longest Non-decreasing Subarray From Two Arrays
Given two length-n arrays, choose for each index either nums1[i] or nums2[i] to form nums3 so as to maximize the length of a contiguous non-decreasing subarray in nums3. With n up to 1e5, the problem is solved in O(n) by scanning and maintaining the longest non-decreasing subarray ending at each index for the two possible choices.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.