The Delete Columns to Make Sorted II interview question is a greedy string optimization problem. You are given a grid of equal-length strings. You need to delete the minimum number of columns such that the remaining characters in each row, when read as a full word, form a list that is lexicographically sorted. Unlike the first version, a column only needs to be "sorted" if the rows aren't already distinguished by a previous column. This Delete Columns to Make Sorted II coding problem is a test of row-dependency logic.
Google uses this to test a candidate's ability to maintain state across column traversals. It evaluates if you can distinguish between "columns that must be sorted" and "columns where row order is already finalized." It’s a higher-level grid problem that requires careful boolean tracking.
This utilizes the Array, String, Greedy interview pattern.
Grid: ["ca", "bb", "ac"]
Whenever row order depends on multiple columns, use a "finalized" or "sorted" flag for each row pair. Once a pair is strictly ordered (e.g., 'a' < 'b'), the values in subsequent columns for that pair no longer matter.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Largest Number After Mutating Substring | Medium | Solve | |
| Split Concatenated Strings | Medium | Solve | |
| Find Permutation | Medium | Solve | |
| Minimum Time to Make Rope Colorful | Medium | Solve | |
| Largest Number | Medium | Solve |