Skip to content

Latest commit

 

History

History

944-DeleteColumnstoMakeSorted

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Delete Columns to Make Sorted

Problem can be found in here!

def minDeletionSize(strs: List[str]) -> int:
    deleted_columns = 0

    for column in zip(*strs):
        for i in range(1, len(column)):
            if column[i-1] > column[i]:
                deleted_columns += 1
                break

    return deleted_columns

Time Complexity: O(nm), Space Complexity: O(1), where n is the length of array strs and m is the length of an element in the array.