Dynamic Programming21 sections · 916 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 = nLIS 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: 53=25 - 3 = 2. The answer is simply nLISn - LIS length. Any element not in the LIS must be removed.