[LeetCode] Minimum Prefix Removal to Make Array Strictly Increasing

3818. 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.

1
2
3
4
5
6
7
8
9
class Solution {
public:
int minimumPrefixLength(vector<int>& nums) {
for(int i = nums.size() - 1; i; i--) {
if(nums[i-1] >= nums[i]) return i;
}
return 0;
}
};
Author: Song Hayoung
Link: https://songhayoung.github.io/2026/09/04/PS/LeetCode/minimum-prefix-removal-to-make-array-strictly-increasing/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.