2022-5-12 每日一题-leetcode
作者:互联网
题目链接:https://leetcode.cn/problems/delete-columns-to-make-sorted/
个人题解:直接遍历即可,暴力两重循环
代码:
class Solution {
public:
int minDeletionSize(vector<string>& strs) {
int n=strs[0].size(),m=strs.size();
int res=0;
for(int j=0;j<n;j++){
for(int i=0;i<m-1;i++){
if(strs[i][j]>strs[i+1][j]){
res++;
break;
}
}
}
return res;
}
};
运行截图:
标签:12,int,res,strs,2022,题解,leetcode,size 来源: https://www.cnblogs.com/cytcnblogs/p/16260814.html