Re: [閒聊] 每日leetcode

作者: DJYOMIYAHINA (通通打死)   2024-12-12 22:40:54
def pickGifts(self, gifts: List[int], k: int) -> int:
pq = [-g for g in gifts]
heapify(pq)
for i in range(k):
cur_num = -heappop(pq)
heappush(pq, -int(cur_num**0.5))
return -sum(pq)
題目有夠難懂 姆咪
直接用int(**0.5)我也不知道會不會有意外
看起來是沒有

Links booklink

Contact Us: admin [ a t ] ucptt.com