Tap here to switch tabs
Problem
Submissions

Problem: Longest Non-decreasing Subarray From Two Arrays

med
30 min
Try to solve the Longest Non-decreasing Subarray From Two Arrays problem.

Statement

You are given two 00-indexed integer arrays nums1 and nums2, each of length n.

You can create an array nums3 of length n by choosing nums3[i] to be either nums1[i] or nums2[i] for each index i where 0≤0 \leq i <n< n.

Return the maximum length of a contiguous non-decreasing subarray in nums3.

Constraints:

  • 1≤1 \leq nums1.length $= nums2.length` =n≤105= n \leq 10^5

  • 1≤1 \leq nums1[i], nums2[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Non-decreasing Subarray From Two Arrays

med
30 min
Try to solve the Longest Non-decreasing Subarray From Two Arrays problem.

Statement

You are given two 00-indexed integer arrays nums1 and nums2, each of length n.

You can create an array nums3 of length n by choosing nums3[i] to be either nums1[i] or nums2[i] for each index i where 0≤0 \leq i <n< n.

Return the maximum length of a contiguous non-decreasing subarray in nums3.

Constraints:

  • 1≤1 \leq nums1.length $= nums2.length` =n≤105= n \leq 10^5

  • 1≤1 \leq nums1[i], nums2[i] ≤109\leq 10^9