Class Solution
- java.lang.Object
-
- g1101_1200.s1187_make_array_strictly_increasing.Solution
-
public class Solution extends Object
1187 - Make Array Strictly Increasing.Hard
Given two integer arrays
arr1andarr2, return the minimum number of operations (possibly zero) needed to makearr1strictly increasing.In one operation, you can choose two indices
0 <= i < arr1.lengthand0 <= j < arr2.lengthand do the assignmentarr1[i] = arr2[j].If there is no way to make
arr1strictly increasing, return-1.Example 1:
Input: arr1 = [1,5,3,6,7], arr2 = [1,3,2,4]
Output: 1
Explanation: Replace
5with2, thenarr1 = [1, 2, 3, 6, 7].Example 2:
Input: arr1 = [1,5,3,6,7], arr2 = [4,3,1]
Output: 2
Explanation: Replace
5with3and then replace3with4.arr1 = [1, 3, 4, 6, 7].Example 3:
Input: arr1 = [1,5,3,6,7], arr2 = [1,6,3,3]
Output: -1
Explanation: You can’t make
arr1strictly increasing.Constraints:
1 <= arr1.length, arr2.length <= 20000 <= arr1[i], arr2[i] <= 10^9
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intmakeArrayIncreasing(int[] arr1, int[] arr2)
-