Delete Columns to Make Sorted LeetCode solution in Python

1
# Runtime: 330 ms (Top 23.27%) | Memory: 14.6 MB (Top 66.82%)
2

3

4
class Solution:
5
def minDeletionSize(self, strs: List[str]) -> int:
6

7
cols = {}
8
l = len(strs)
9
l_s = len(strs[0])
10
delete = set()
11
for i in range(l):
12
for col in range(l_s):
13
if col in cols:
14
if cols[col] > strs[i][col]:
15
delete.add(col)
16
cols[col] = strs[i][col]
17
return len(delete)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0