Posted on 2023-01-03 18:38
Uriel 閱讀(43)
評論(0) 編輯 收藏 引用 所屬分類:
閑來無事重切Leet Code 、
大水題
給出一個二維字符list,查看每一列,計算有多少列從上到下不是按字母順序排列的
1 #944
2 #Runtime: 138 ms (Beats 71.88%)
3 #Memory: 14.4 MB (Beats 90.63%)
4
5 class Solution(object):
6 def minDeletionSize(self, strs):
7 """
8 :type strs: List[str]
9 :rtype: int
10 """
11 ans = 0
12 for i in range(len(strs[0])):
13 t = [s[i] for s in strs]
14 #print(''.join(sorted(t)))
15 if ''.join(sorted(t)) != ''.join(t):
16 ans += 1
17 return ans