2025-08-16 08:32:58 +0000 UTC
Remove One Element to Make the Array Strictly Increasing
Categories:
Links
Code
class Solution:
def canBeIncreasing(self, nums: List[int]) -> bool:
removed = False
length = len(nums)
for i in range(length - 1):
cur, nxt = nums[i], nums[i + 1]
if nxt > cur:
continue
if removed:
return False
removed = True
if (
i > 0 and nums[i - 1] >= nxt
) and (
i + 2 < length and cur >= nums[i + 2]
):
return False
return True