Description
Submission
class Solution {
public:
int minDeletionSize(vector<string>& strs) {
int n = strs.size();
int l = strs[0].length();
vector<int> cmp(n, 0);
int ret = 0;
for(int i = 0; i < l; ++i) {
vector<int> newCmp(n, 0);
bool merge = true;
for(int j = 1; j < n; ++j) {
if(cmp[j]) continue;
if(strs[j-1][i] > strs[j][i]) {
ret++;
merge = false;
break;
}
if(strs[j-1][i] < strs[j][i]) {
newCmp[j] = 1;
}
}
if(merge) {
for(int i = 0; i < n; ++i) {
if(newCmp[i]) cmp[i] = 1;
}
}
}
return ret;
}
};