Google | Onsite | Remove at most K element to make array increasing
11384

Given an array, please check if we can remove at most one element to make it strictly increasing.

Example 1:

Input: [1, 2, 3, 7, 5, 6]
Output: true

Example 2:

Input: [1, 2, 3, 7, 8, 4, 5]
Output: false

Follow-up 1:
What if at most 2?


Follow-up 2:
what if at most k?

firstly see K = 1, I focus too much on remove element, but it's just a longest increasing sequence problem.

reference : https://www.geeksforgeeks.org/convert-to-strictly-increasing-integer-array-with-minimum-changes/

return (arr.size() - longest_increasing_element_cnt) >= K;

But I realize til now...

Comments (32)