Mid/SeniorArray

Minimum Prefix Removal to Make Array Strictly Increasing

You are given an integer array nums.

You need to remove exactly one prefix, possibly empty, from nums.

Return an integer denoting the minimum length of the removed prefix such that the remaining array is strictly increasing.

Example 1
Inputnums = [1,-1,2,3,3,4,5]
Output4
Removing the prefix [1, -1, 2, 3] leaves the remaining array [3, 4, 5], which is strictly increasing.
Example 2
Inputnums = [4,3,-2,-5]
Output3
Removing the prefix [4, 3, -2] leaves the remaining array [-5], which is strictly increasing.

Constraints

  • 1 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9

Asked at 1 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