Remove One Element to Make the Array Strictly Increasing - Problem
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).
Input & Output
Example 1 — Can Remove One Element
$
Input:
nums = [1,2,10,5,7]
›
Output:
true
💡 Note:
Remove the element at index 2 (value 10) to get [1,2,5,7], which is strictly increasing: 1 < 2 < 5 < 7
Example 2 — Already Strictly Increasing
$
Input:
nums = [2,3,1,2]
›
Output:
false
💡 Note:
No single removal can make this strictly increasing. Removing any one element still leaves violations
Example 3 — Already Strictly Increasing
$
Input:
nums = [1,2,3]
›
Output:
true
💡 Note:
Already strictly increasing: 1 < 2 < 3, so return true
Constraints
- 2 ≤ nums.length ≤ 1000
- 1 ≤ nums[i] ≤ 1000
Visualization
Tap to expand
Understanding the Visualization
1
Input Array
Given array [1,2,10,5,7] with violation at position 2
2
Find Violation
Element 10 breaks the increasing sequence
3
Remove Element
After removing 10, we get [1,2,5,7] which is strictly increasing
Key Takeaway
🎯 Key Insight: At most one element can be 'out of place' for the array to be fixable by removing exactly one element
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code