Python 3 | Greedy, DP (28 ms) | Explanation
Explanation\n- This idea is simple but there are some thing we need to be careful about\n- For each column, if we found any row pairs (i, i+1) not in order, the
### Explanation\n- This idea is simple but there are some thing we need to be careful about\n- For each column, if we found any row pairs `(i, i+1)` not in order, then we need to remove this column\n\t- but we do this only if their previous column is not in order, e.g.\n\t- There is a tie in column 1, so we can\'t say they are in order, then we compare column 2 \n\t\t- `ak`\n\t\t- `ab`\n\t- There is no tie in column 1, we don\'t care about column 2\n\t\t- `ak`\n\t\t- `bb`\n\t- use `in_order` to store relation between rows\n### Implementation\n```\nclass Solution:\n    def minDeletionSize(self, A: List[str]) -> int:\n        m, n = len(A), len(A[0])\n        ans, in_order = 0, [False] * (m-1)\n        for j in range(n):\n            tmp_in_order = in_order[:]\n            for i in range(m-1):\n\t\t\t\t# previous step, rows are not in order; and current step rows are not in order, remove this column\n                if not in_order[i] and A[i][j] > A[i+1][j]: ans += 1; break  \n\t\t\t\t# previous step, rows are not in order, but they are in order now\n                elif A[i][j] < A[i+1][j] and not in_order[i]: tmp_in_order[i] = True\n\t\t\t# if column wasn\'t removed, update the row order information\n            else: in_order = tmp_in_order  \n            # not necessary, but speed things up\n            if all(in_order): return ans   \n        return ans\n```
['Dynamic Programming', 'Greedy', 'Python', 'Python3']