#define rep(i, a, n) for (int i = a; i < n; ++i) #define per(i, a, n) for (int i = n - 1; i >= a; --i) #define all(x) x.begin(), x.end() #define mp make_pair #define pb push_back #define np next_permutation #define fi first #define se second
boolcompare(vector<string>& A) { rep(i, 1, A.size()) { if (A[i - 1] > A[i]) { returnfalse; } } returntrue; }
classSolution { public: intminDeletionSize(vector<string>& A) { vector<string> test(A.size(), ""); int ans = 0; rep(i, 0, A.front().size()) { rep(j, 0, A.size()) { test[j].pb(A[j][i]); } if (!compare(test)) { ans++; rep(j, 0, A.size()) { test[j].pop_back(); } } } return ans; } };