【leetcode】944. Delete Columns to Make Sorted

class Solution {
    public int minDeletionSize(String[] A) {
        String str = A[0];
        int countD = 0;
        int length = str.length();
        for (int i=0; i<length; i++) {
            char last = A[0].charAt(i);
            for (int j=1; j<A.length; j++) {
                char curr = A[j].charAt(i);
                if (curr<last) {
                    countD ++;
                    break;
                }
                else
                    last = curr;
            }
        }
            return countD;
    }
}

猜你喜欢

转载自blog.csdn.net/Art1st_D/article/details/89441192
今日推荐