Delete Columns to Make Sorted II
Complexity
Time complexity: O(N * Log N)

Space complexity: O(N)
Code


# Complexity
- Time complexity: O(N * Log N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python []
class Solution(object):
    def minDeletionSize(self, strs):
        """
        :type strs: List[str]
        :rtype: int
        """
        n, m = len(strs), len(strs[0])
        delete_count = 0
        sorted_rows = [False] * (n - 1)

        for col in range(m):
            if all(sorted_rows[i] or strs[i][col] <=  strs[i + 1][col] for i in range(n - 1)):
                for i in range(n - 1):
                    if strs[i][col] < strs[i + 1][col]:
                        sorted_rows[i] = True
            
            else:
                delete_count += 1

        return delete_count
```
['Array', 'String', 'Greedy', 'Python']