3818. Minimum Prefix Removal to Make Array Strictly Increasing Medium

@problem@discussion
#Array



1/**
2 * [3818] Minimum Prefix Removal to Make Array Strictly Increasing
3 *
4 * You are given an integer array nums.
5 * You need to remove exactly one prefix (possibly empty) from nums.
6 * Return an integer denoting the minimum length of the removed <span data-keyword="array-prefix">prefix</span> such that the remaining array is <span data-keyword="strictly-increasing-array">strictly increasing</span>.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">nums = [1,-1,2,3,3,4,5]</span>
11 * Output: <span class="example-io">4</span>
12 * Explanation:
13 * Removing the prefix = [1, -1, 2, 3] leaves the remaining array [3, 4, 5] which is strictly increasing.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">nums = [4,3,-2,-5]</span>
18 * Output: <span class="example-io">3</span>
19 * Explanation:
20 * Removing the prefix = [4, 3, -2] leaves the remaining array [-5] which is strictly increasing.
21 * </div>
22 * <strong class="example">Example 3:
23 * <div class="example-block">
24 * Input: <span class="example-io">nums = [1,2,3,4]</span>
25 * Output: <span class="example-io">0</span>
26 * Explanation:
27 * The array nums = [1, 2, 3, 4] is already strictly increasing so removing an empty prefix is sufficient.
28 * </div>
29 *  
30 * Constraints:
31 * 
32 * 	1 <= nums.length <= 10^5
33 * 	-10^9 <= nums[i] <= 10^9​​​​​​​
34 * 
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/minimum-prefix-removal-to-make-array-strictly-increasing/
39// discuss: https://leetcode.com/problems/minimum-prefix-removal-to-make-array-strictly-increasing/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44    pub fn minimum_prefix_length(nums: Vec<i32>) -> i32 {
45        0
46    }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_3818() {
57    }
58}
59

Back
© 2026 bowen.ge All Rights Reserved.