Skip to content

Practice Make Array Strictly Increasing

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1187
LeetCode Problem

Make Array Strictly Increasing

Problem Statement

Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing. In one operation, you can choose two indices 0 <= i < arr1.length and 0 <= j < arr2.length and do the assignment arr1[i] = arr2[j]. If there is no way to make arr1 strictly increasing, return -1.

Source: Make Array Strictly Increasing on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

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

# Example 3

Input
arr1 = [1,5,3,6,7], arr2 = [1,6,3,3]
Output
-1

Constraints

1 <= arr1.length, arr2.length <= 2000
0 <= arr1[i], arr2[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Make Array Strictly Increasing.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.