C++ 12 ms brute force
We analyze words one-by-one. If in a word i a character j breaks the lexicographic order (A[i - 1][j] > A[i][j]), we add j column to the list of deleted columns
We analyze words one-by-one. If in a word ```i``` a character ```j``` breaks the lexicographic order (```A[i - 1][j] > A[i][j]```), we add ```j``` column to the list of deleted columns (I am using a hash set for O(1) operations).\n\nAfter we deleted a column, we need to restart the process from the beginning. The reason is that we a deleted column can break the lexicographic order for words we already analyzed. Note that now we ignore all columns that are already in the "deleted" list.\n```\nint minDeletionSize(vector<string>& A) {\n    unordered_set<int> di;\n    for (auto i = 1; i < A.size(); ++i) {\n        for (auto j = 0; j < A[i].size(); ++j) {\n            if (di.count(j) > 0 || A[i - 1][j] == A[i][j]) continue;\n            if (A[i - 1][j] > A[i][j]) {\n                di.insert(j);\n                i = 0;\n            }\n            break;\n        }\n    }\n    return di.size();\n}\n```
[]