Dynamic Programming21 sections · 915 units
Open in Course

Minimum Deletions for Sorted - Problem Statement

LIS application

Given an array, find minimum deletions to make it sorted (non-decreasing). observation: keep the longest non-decreasing subsequence, delete the rest.

Answer = n−LIS lengthn - \text{LIS length}. For non-decreasing (allowing equal elements), modify LIS: use ≤\leq instead of << in the comparison. Example: [5,3,4,9,1][5, 3, 4, 9, 1]. Longest non-decreasing: [3,4,9][3, 4, 9] length 33. Deletions: 5−3=25 - 3 = 2. The answer is simply n−LISn - LIS length. Any element not in the LIS must be removed.