Skip to content

Latest commit

 

History

History
20 lines (18 loc) · 485 Bytes

944.md

File metadata and controls

20 lines (18 loc) · 485 Bytes

944. Delete Columns to Make Sorted

Solution 1 (time O(mn), space O(1))

class Solution(object):
    def minDeletionSize(self, strs):
        """
        :type strs: List[str]
        :rtype: int
        """
        n, m = len(strs), len(strs[0])
        ans = 0
        for i in range(m):
            for j in range(1, n):
                if strs[j][i] < strs[j - 1][i]:
                    ans += 1
                    break
        return ans