class Solution:
def minDeletionSize(self, strs: List[str]) -> int:
count = 0
for i in range(len(strs[0])):
w = []
k=[]
for j in range(len(strs)):
d=strs[j][i]
w.append(d)
k.append(d)
k.sort()
if k!=w:
count+=1
return (count)
#" using unzip "
class Solution:
def minDeletionSize(self, A: List[str]) -> int:
d = 0
for col in zip(*A):
if list(col)!=sorted(col):
d+=1
return d
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter