LeetCode solutions

2020. Remove One Element to Make the Array Strictly Increasing

My accepted Python solution to LeetCode problem 2020, Remove One Element to Make the Array Strictly Increasing, running in 191ms.

  • Difficulty: Easy
  • Python
  • Runtime 191ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 191ms, memory 17.3MB, accepted 2025-12-30.

python
class Solution:
    def canBeIncreasing(self, nums: List[int]) -> bool:
        def isStrictlyIncreasing(arr):
            for i in range(1, len(arr)):
                if arr[i] <= arr[i-1]:
                    return False
            return True
        
        # Check if already strictly increasing
        if isStrictlyIncreasing(nums):
            return True
        
        # Try removing each element
        for i in range(len(nums)):
            new_arr = nums[:i] + nums[i+1:]
            if isStrictlyIncreasing(new_arr):
                return True
        
        return False

Source