Delete Columns to Make Sorted II
You are given an array of n strings strs, all of the same length.
You may choose any deletion indices, and you delete all the characters in those indices for each string.
For example, if strs = ["abcdef", "uvwxyz"] and the deletion indices are {0, 2, 3}, then the final array after deletions is ["bef", "vyz"].
Suppose you chose a set of deletion indices answer such that after deletions, the final array has its elements in lexicographic order, meaning strs[0] <= strs[1] <= strs[2] <= ... <= strs[n - 1]. Return the minimum possible value of answer.length.
strs = ["ca","bb","ac"]1strs = ["xc","yb","za"]0Constraints
- n == strs.length
- 1 <= n <= 100
- 1 <= strs[i].length <= 100
- strs[i] consists of lowercase English letters.
Asked at 3 companies
Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.