The Delete Columns to Make Sorted III interview question is the most advanced version of the column deletion series. You need to delete columns such that each remaining string is lexicographically sorted. The twist: you want to find the maximum number of columns you can keep, or the minimum you must delete. This Delete Columns to Make Sorted III coding problem is actually a "Longest Increasing Subsequence" (LIS) problem in a 2D context.
Google asks this to see if a candidate can reduce a grid-based string problem to a classic Dynamic Programming task. It requires realizing that if we keep column i and then keep column j (j > i), then for every row, the character at row[i] must be <= the character at row[j]. It evaluates your ability to handle multi-row constraints in a single DP state.
This follows the Array, String, Dynamic Programming interview pattern.
Grid: ["baaa", "abcd"]
When you need to pick a subsequence of items that satisfy a property, always think of the Longest Increasing Subsequence pattern. If the property involves multiple rows, just add an extra loop to validate the condition across all rows.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Number of Ways to Form a Target String Given a Dictionary | Hard | Solve | |
| Sentence Screen Fitting | Medium | Solve | |
| Ones and Zeroes | Medium | Solve | |
| Longest Unequal Adjacent Groups Subsequence II | Medium | Solve | |
| Construct String with Minimum Cost | Hard | Solve |