leetcode 944. Delete Columns to Make Sorted

It is marked as easy, and it's really very easy.

class Solution {
    public int minDeletionSize(String[] A) {
        int D = 0;
        int N = A[0].length();
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < A.length - 1; ++j) {
                if (A[j].charAt(i) > A[j + 1].charAt(i)) {
                    D += 1;
                    break;
                }
            }
        }
        return D;
    }
}
posted on 2019-03-19 21:20  王 帅  阅读(71)  评论(0编辑  收藏  举报