JuniorArray

Remove One Element to Make the Array Strictly Increasing

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.

Example 1
Inputnums = [1,2,10,5,7]
Outputtrue
By removing 10 at index 2 from nums, it becomes [1, 2, 5, 7], which is strictly increasing.
Example 2
Inputnums = [2,3,1,2]
Outputfalse
No matter which single element is removed, the resulting array is not strictly increasing.

Constraints

  • 2 <= nums.length <= 1000
  • 1 <= nums[i] <= 1000

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate