Re: [闲聊] 每日leetcode

楼主: DJYOSHITAKA (Evans)   2024-06-05 22:03:38
怎么只营10%
懒的研究了
一生就只赢10%了
def commonChars(self, words: List[str]) -> List[str]:
n = len(words)
cnt = [2**32-1 for _ in range(26)]
# cnt
for i in range(n):
cnt_cur = [0 for _ in range(26)]
for c in words[i]:
cnt_cur[ord(c)-ord('a')]+=1
for i in range(26):
cnt[i] = min(cnt[i], cnt_cur[i])
ans = []
for i in range(26):
for j in range(cnt[i]):
ans.append(chr(ord('a')+i))
return ans
作者: Rushia (みけねこ的鼻屎)   2024-06-05 22:04:00
多提交几次 跟凹总力战一样
作者: sustainer123 (caster)   2024-06-05 22:45:00
你直接开字典不就好了 干嘛阵列我是赢90% 但我其实不太清楚我在写三小

Links booklink

Contact Us: admin [ a t ] ucptt.com