C++ 8ms
Straightforward:\ncompare the substr(0...j) and if we found they are not in ascending order, we change jth colum to \'*\' or any other character. If two strings
Straightforward:\ncompare the substr(0...j) and if we found they are not in ascending order, we change jth colum to \'*\' or any other character. If two strings are the same, we need check later columns.\nComplexity O(MN)\n```\n    int minDeletionSize(vector<string>& A) {\n        //previous col is sorted then is over\n        int ans=0;\n        int m=A.size(),n=A[0].size();\n        for(int j=0;j<n;j++)\n        {\n            bool need_next=0;\n            int i=1;\n            for(;i<m;i++)\n            {\n                if(A[i].substr(0,j+1)<A[i-1].substr(0,j+1)) {ans++;break;}\n                else if(A[i].substr(0,j)==A[i-1].substr(0,j)) need_next=1;\n            }\n            if(i==m && !need_next) return ans; //sorted\n            if(i<m) for(int k=0;k<m;k++) A[k][j]=\'*\';\n        }\n        return ans;\n    }\n```\t
[]