Java Solution O(N*K)
The idea is to proceed from left to right for each column independently. Each time we find an ordered column the only way that less significant columns can viol
The idea is to proceed from left to right for each column independently. Each time we find an ordered column the only way that less significant columns can violate ordering is at the positions where the characters are equal in the current column: all the rows that have the same characters should be ordered in future iterations. To remember what adjacent rows are grouped by the same character I used a mask with levels. Note that we never want to remove a sorted column as they help reduce the possible order violations.\n ```\n   public int minDeletionSize(String[] strs) {\n        int[] mask = new int[strs.length]; // all 0s means all rows should be sorted\n        int s = strs[0].length();\n        int k = 0;\n        for (int j = 0; j < s; ++j) {\n            int[] newMask = new int[strs.length]; // update for the mask if we find an ordered column\n            int i = 0;\n            int ii = 0;\n            for (; i < strs.length - 1; ++i) {\n                if (mask[i] != mask[i + 1]) {\n                    // adjacent rows are different in the mask: they can have any order \n                    newMask[i] = ii++;\n                    continue;\n                }\n                // adjacent rows are equal in the mask: they should be sorted\n                char curr = strs[i].charAt(j);\n                char next = strs[i + 1].charAt(j);\n                if (curr > next) {\n                    // lexicographic order is violated\n                    break;                    \n                }\n                newMask[i] = ii;\n                if (curr < next) {\n                    // make the mask indices differ if the chars in the current col differ\n                    ++ii;\n                }\n            }\n            \n            if (i == strs.length - 1) {\n                // the masked rows are ordered, update the mask\n                newMask[i] = ii;\n                mask = newMask;\n            } else {\n                // the masked rows violate ordering, remove this column\n                ++k;\n            }\n        }\n        return k;\n    }\n\t```
[]