题目:
https://leetcode-cn.com/problems/delete-columns-to-make-sorted/description/:
思路:
cba
daf
ghi
竖着分析
贪心策略所有不符合升序的这一列删除。
codes:
class Solution {
public int minDeletionSize(String[] A) {
if(A == null || A.length == 0) return 0;
//所有小写字母串的长度都相同
int count = 0;
for(int i = 0;i < A[0].length();i++){
for(int j = 0;j < A.length - 1;j++){
if(A[j].charAt(i) > A[j+1].charAt(i)){
count++;
break;
}
}
}
return count;
}
}