LeetCode 944. 删列造序

思路

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Solution {
public:
int minDeletionSize(vector<string>& strs) {
int l=strs[0].length();
int n=strs.size();
int res=0;
for(int i=0;i<l;i++){
for(int j=0;j<n-1;j++){
if(strs[j][i]>strs[j+1][i]){
res++;
break;
}
}
}
return res;
}
};

参考