Imagine you have an array of integers that's almost perfect - it would be strictly increasing if you could just remove exactly one element! Your task is to determine whether this transformation is possible.
Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise.
Special case: If the array is already strictly increasing, you should return true (you can remove any element and still maintain the property).
Definition: An array is strictly increasing if nums[i-1] < nums[i] for each valid index i where 1 ≤ i < nums.length.
Examples:
[1, 2, 10, 5, 7]→true(remove 10 to get [1, 2, 5, 7])[2, 3, 1, 2]→false(no single removal works)[1, 2, 3]→true(already strictly increasing)
Input & Output
Visualization
Time & Space Complexity
Two passes through array, each taking O(n) time
Storage for violation positions in worst case
Constraints
- 2 ≤ nums.length ≤ 1000
- 1 ≤ nums[i] ≤ 1000
- Must remove exactly one element
- Resulting array must be strictly increasing (no equal elements allowed)