Skip to content

Commit

Permalink
Create delete-cols-sorted.py
Browse files Browse the repository at this point in the history
deletes columns in list to make it sorted
  • Loading branch information
gabedonnan authored Jan 12, 2023
1 parent 8987ced commit 25daafb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions delete-cols-sorted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution(object):
def minDeletionSize(self, strs):
"""
:type strs: List[str]
:rtype: int
"""
count = 0
removal = []
x = list(range(len(strs[0])))
for row_num in range(len(strs)):
for col_num in x:
if row_num > 0:
if strs[row_num][col_num] < strs[row_num-1][col_num]:
removal.append(col_num)
count += 1
x = [elem for elem in x if elem not in removal]
#removal = []
#print(removal)
return count

0 comments on commit 25daafb

Please sign in to comment.