0
点赞
收藏
分享

微信扫一扫

每日一题 leetcode 944. 删列造序 java

三分梦_0bc3 2022-05-12 阅读 70
java

https://leetcode.cn/problems/delete-columns-to-make-sorted/

class Solution {
    public int minDeletionSize(String[] strs) {
        int m=strs.length;
        int n=strs[0].length();
        int count=0;
        for(int i=0;i<n;i++){
            char before='a';
            for(int j=0;j<m;j++){
                if(strs[j].charAt(i)>=before){
                    before=strs[j].charAt(i);
                }
                else{
                    count++;
                    break;
                }
            }
        }
        return count;
    }
}
举报

相关推荐

0 条评论