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 i with 1 <= i < len(nums).
Function Signature
def can_be_increasing(nums: List[int]) -> bool:
Rules
-
Exactly one element is removed, and the remaining elements keep their original order.
-
Equal neighbors break the strictly increasing property.
Constraints
-
2 <= len(nums) <= 1000
-
1 <= nums[i] <= 1000
Examples
Input: nums = [1, 2, 10, 5, 7]
Output: True
Removing the element at index 2 (value 10) gives [1, 2, 5, 7], which is strictly increasing.
Input: nums = [2, 3, 1, 2]
Output: False
The four possible removals give [3, 1, 2], [2, 1, 2], [2, 3, 2] and [2, 3, 1], and none of them is strictly increasing.
Input: nums = [1, 2, 3]
Output: True
The array is already strictly increasing. Removing any one element, for example the last, leaves [1, 2], which is still strictly increasing.