Make Array Strictly Increasing

Hard

Description

Given two integer arrays arr1 and arr2, you may replace elements of arr1 with any elements from arr2. Return minimum replacements to make arr1 strictly increasing.

Examples

Input:arr1 = [1,5,3,6,7], arr2 = [1,3,2,4]
Output:1
Explanation:

Replace 5 with 2.

Input:arr1 = [2,1,3], arr2 = [4,5,6]
Output:1
Explanation:

One replacement operation makes the array strictly increasing.

Input:arr1 = [10,20,30], arr2 = [15,25]
Output:0
Explanation:

The array [10,20,30] is already strictly increasing, so no operations are needed.

Constraints

  • 1 ≤ arr1.length ≤ 2000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!