Re: [閒聊] 每日leetcode已回收
剩我不是one-liner了
最近要養成每天早上刷題的習慣
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
a = defaultdict(int)
for num in nums1:
a[num] += 1
ans = []
for num in nums2:
if a[num] > 0:
ans.append(num)
a[num] -= 1
return ans
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1719879434.A.D4C.html
→
07/02 08:20,
1年前
, 1F
07/02 08:20, 1F
推
07/02 08:23,
1年前
, 2F
07/02 08:23, 2F
討論串 (同標題文章)
完整討論串 (本文為第 434 之 1554 篇):