Find the minimum array length after repeatedly removing three consecutive elements forming an arithmetic progression.
Unlock detailed company stats for this questionUpgrade
Given an integer array a, in one operation you can pick 3 consecutive elements that form an arithmetic progression and remove them; the left and right parts then join, so new elements can become adjacent. Perform any number of operations and return the minimum possible length of the array. Example: a = [1, 5, 6, 7, 4, 7] -> remove (5, 6, 7) -> [1, 4, 7] -> remove (1, 4, 7) -> [], output 0. The catch: removals can nest, so a simple index-based DP fails; the intended solution is interval DP.
Format · 60-minute online DSA round.
Community answers
No answers contributed by the community yet.
Related questions
Find the length of the longest contiguous arithmetic progression subarray when you may change at most one element.Find the minimum number of no-repeat segments after removing one letter.Find the minimum and maximum elements in an array using minimum comparisons.Related courses

Course

Course
Course
