Delete Columns to Make Sorted III
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.
Suppose you choose a set of deletion indices answer such that after deletions, the final array has every string (row) in lexicographic order. That is, for every row, its remaining characters must be nondecreasing from left to right.
Return the minimum possible value of answer.length.
Example 1
Input
strs = ["babca","bbazb"]Output
3After deleting columns 0, 1, and 4, the final array is ["bc", "az"], and both rows are individually in lexicographic order.
Example 2
Input
strs = ["edcba"]Output
4If fewer than 4 columns are deleted, the only row will not be lexicographically sorted.
Constraints
- n == strs.length
- 1 <= n <= 100
- 1 <= strs[i].length <= 100
- strs[i] consists of lowercase English letters.