#1909
Easy Algorithms Remove one element to make the array strictly increasing
Array
29.6% acceptance
Feb 25, 2026
1316
348
Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true.
The array nums is strictly increasing if nums[i - 1] < nums[i] for each index (1 <= i < nums.length).
Solution
Rust
Time O(n)
Space O(1)
impl Solution {
pub fn can_be_increasing(nums: Vec<i32>) -> bool {
let check = |skip: usize| -> bool {
let mut prev = i32::MIN;
for (i, &v) in nums.iter().enumerate() {
if i == skip { continue; }
if v <= prev { return false; }
prev = v;
}
true
};
for i in 1..nums.len() {
if nums[i] <= nums[i - 1] {
return check(i) || check(i - 1);
}
}
true
}
}