Magicsheet logo

Remove One Element to Make the Array Strictly Increasing

Easy
95.1%
Updated 6/1/2025

Asked by 4 Companies

Topics

Remove One Element to Make the Array Strictly Increasing

What is this problem about?

The Remove One Element to Make the Array Strictly Increasing interview question asks whether you can remove at most one element from an integer array to make the entire array strictly increasing (each element greater than the previous). You do not have to remove an element — if the array is already strictly increasing, return true.

Why is this asked in interviews?

This problem is asked at Goldman Sachs, eBay, Amazon, and Google because it requires careful boundary reasoning rather than brute force. A naive approach removes each element and checks if the remainder is increasing — O(n^2). The efficient O(n) approach finds the first violation point and then checks only two candidates for removal: the violating element or its predecessor. This tests targeted problem decomposition.

Algorithmic pattern used

The pattern is linear scan with two targeted checks. Scan the array for the first index i where nums[i] >= nums[i+1] (a violation). If none exists, return true. Otherwise, check two options:

  1. Remove nums[i] — is the resulting array strictly increasing?
  2. Remove nums[i+1] — is the resulting array strictly increasing?

Write a helper isIncreasing(arr, skip_index) that validates the array while skipping the given index. Return true if either option works.

Example explanation

Array: [1, 2, 10, 5, 7].

  • Violation at i=2: nums[2]=10 >= nums[3]=5.
  • Option 1: Remove index 2 (value 10) → [1, 2, 5, 7]. Strictly increasing? Yes → return true.
  • (Option 2: Remove index 3 (value 5) → [1, 2, 10, 7]. Not increasing, but we already found a valid option.)

Common mistakes candidates make

  • Checking only one candidate for removal (either only i or only i+1) and missing valid cases.
  • Using an O(n^2) approach by trying to remove every element.
  • Not handling the edge case where the array has length 1 or 2.
  • Implementing the isIncreasing helper with an off-by-one when skipping the target index.

Interview preparation tip

For the Remove One Element to Make the Array Strictly Increasing coding problem, the array interview pattern relies on finding the first violation and testing exactly two removal candidates. This is much faster than brute force. Practice writing the clean helper function that skips an index — it keeps the main logic readable. Google interviewers appreciate when you explain why only two candidates need to be checked, as this shows you understand the mathematical constraints of the problem.

Similar Questions