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