Description
Given an array of n strings strs, all of the same length, find the number of columns that are not sorted lexicographically. Delete those columns.
Examples
Input:
strs = ["cba","daf","ghi"]Output:
1Explanation:
Column 1 unsorted.
Input:
strs = ["a","b"]Output:
0Explanation:
Each string has only one column, and that column ('a','b') is already sorted. No columns need to be deleted.
Input:
strs = ["abc","def","ghi"]Output:
0Explanation:
All three columns are sorted: column 0 has 'a'<'d'<'g', column 1 has 'b'<'e'<'h', and column 2 has 'c'<'f'<'i'. No columns need to be deleted.
Constraints
- •
1 ≤ n ≤ 100