1187. Make Array Strictly Increasing Hard

@problem@discussion
#Array#Binary Search#Dynamic Programming



1/**
2 * [1187] Make Array Strictly Increasing
3 *
4 * Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing.
5 * 
6 * 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].
7 * 
8 * If there is no way to make arr1 strictly increasing, return -1.
9 * 
10 *  
11 * Example 1:
12 * 
13 * 
14 * Input: arr1 = [1,5,3,6,7], arr2 = [1,3,2,4]
15 * Output: 1
16 * Explanation: Replace 5 with 2, then arr1 = [1, 2, 3, 6, 7].
17 * 
18 * 
19 * Example 2:
20 * 
21 * 
22 * Input: arr1 = [1,5,3,6,7], arr2 = [4,3,1]
23 * Output: 2
24 * Explanation: Replace 5 with 3 and then replace 3 with 4. arr1 = [1, 3, 4, 6, 7].
25 * 
26 * 
27 * Example 3:
28 * 
29 * 
30 * Input: arr1 = [1,5,3,6,7], arr2 = [1,6,3,3]
31 * Output: -1
32 * Explanation: You can't make arr1 strictly increasing.
33 * 
34 *  
35 * Constraints:
36 * 
37 * 
38 * 	1 <= arr1.length, arr2.length <= 2000
39 * 	0 <= arr1[i], arr2[i] <= 10^9
40 * 
41 * 
42 *  
43 */
44pub struct Solution {}
45
46// problem: https://leetcode.com/problems/make-array-strictly-increasing/
47// discuss: https://leetcode.com/problems/make-array-strictly-increasing/discuss/?currentPage=1&orderBy=most_votes&query=
48
49// submission codes start here
50
51impl Solution {
52    pub fn make_array_increasing(arr1: Vec<i32>, arr2: Vec<i32>) -> i32 {
53        0
54    }
55}
56
57// submission codes end
58
59#[cfg(test)]
60mod tests {
61    use super::*;
62
63    #[test]
64    fn test_1187() {
65    }
66}
67


Back
© 2025 bowen.ge All Rights Reserved.