#3818
Medium Algorithms Minimum prefix removal to make array strictly increasing
Array
73.7% acceptance
Mar 16, 2026
54
6
Remove exactly one prefix (possibly empty) from nums.
Return min length of removed prefix such that remaining array is strictly increasing.
Solution
Rust
Time O(n)
Space O(1)
impl Solution {
pub fn minimum_prefix_length(nums: Vec<i32>) -> i32 {
let n = nums.len();
// Find longest strictly increasing suffix
let mut start = n - 1;
while start > 0 && nums[start - 1] < nums[start] {
start -= 1;
}
start as i32
}
}