C++/Python, greedy solution with explanation
We can think about how to constructs the strs meets the requirement.\n\ntraverse columns from left to right,\nif we meet a column whose c[i] > c[i-1] where i in
We can think about how to constructs the strs meets the requirement.\n\ntraverse columns from left to right,\nif we meet a column whose c[i] > c[i-1] where i in [1, number of row),\nwe just remove all non-lexi order columns,\n\nbut if two adjacent letters c[i] == c[i-1],\nif c[i] < c[i-1] in next column, we also should remove next column until we meet c[i] > c[i-1] in a column on the right.\n\nSo, use a bool array lexi record if lexi order of position i >  lexi order of position i - 1,\nthe promise is that  a column is in lexicographic order.\nif all position  is in lexicographic order, cnt == 0, just break, and return ans.\n\ntc is O(mn), sc is O(m).\n\n### python\n```python\nclass Solution:\n    def minDeletionSize(self, strs: List[str]) -> int:\n        m, n = len(strs), len(strs[0])\n        lexi = [False] * m\n        lexi[0] = True\n        cnt = m - 1\n        ans = 0\n        for i in range(n):\n            if cnt == 0:\n                break\n            for j in range(1, m):\n                if lexi[j] == False and strs[j][i] < strs[j-1][i]:\n                    ans += 1\n                    break\n            else:\n                for j in range(1, m):\n                    if lexi[j] == False and strs[j][i] > strs[j-1][i]:\n                        lexi[j] = True\n                        cnt -= 1\n        return ans\n```\n### c++\n```cpp\nclass Solution {\npublic:\n    int minDeletionSize(vector<string>& strs) {\n        int m = strs.size(), n = strs[0].size();\n        vector<bool> lexi (m);\n        lexi[0] = true;\n        int cnt = m - 1, ans = 0;\n        for (int i = 0; i < n; i+=1) {\n            if (cnt == 0) break;\n            bool is_lexi = true;\n            for (int j = 1; j < m; j+=1) {\n                if (lexi[j] == false && strs[j][i] < strs[j-1][i]) {\n                    is_lexi = false; ans += 1; break;\n                }\n            } if (is_lexi) {\n                for (int j = 1; j < m; j+=1)\n                    if (lexi[j] == false && strs[j][i] > strs[j-1][i])\n                        lexi[j] = true, cnt -= 1;\n            }\n        }\n        return ans;\n    }\n};\n```
['Greedy', 'C', 'Python']