955. Delete Columns to Make Sorted II.cpp
Code\n\nclass Solution {\npublic:\n    int minDeletionSize(vector<string>& strs) {\n        int ans = 0, m = size(strs), n = size(strs[0]); \n        vector<int
**Code**\n```\nclass Solution {\npublic:\n    int minDeletionSize(vector<string>& strs) {\n        int ans = 0, m = size(strs), n = size(strs[0]); \n        vector<int> grp(m); \n        for (int j = 0; j < n; ++j) {\n            bool found = false; \n            for (int i = 1; i < m; ++i) \n                if (grp[i-1] == grp[i] && strs[i-1][j] > strs[i][j]) {\n                    ++ans; \n                    found = true; \n                    break; \n                }\n            if (!found) \n                for (int i = 1; i < m; ++i) {\n                    grp[i] = max(grp[i-1], grp[i]); \n                    if (grp[i-1] == grp[i] && strs[i-1][j] < strs[i][j]) grp[i] = i; \n                }\n        }\n        return ans; \n    }\n};\n```
['C']