討論串[閒聊] 每日leetcode
共 1554 篇文章

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者dont (dont)時間1年前 (2024/12/14 09:29), 編輯資訊
0
0
0
內容預覽:
2762. Continuous Subarrays. ## 思路. sliding window. 用counter記錄window裡面的值跟個數. ## Code. ```python. class Solution:. def continuousSubarrays(self, nums: L
(還有365個字)

推噓2(2推 0噓 0→)留言2則,0人參與, 1年前最新作者sixB (6B)時間1年前 (2024/12/13 12:57), 編輯資訊
0
0
0
內容預覽:
2593.. sort by index. 加一個丟三個. #. 看到on解 真的超扯==. 先下坡走到谷底 然後往回加. 這樣只要管一邊. 山的另一側已經先被吃掉了. 到底怎麼想到可以這樣做的. 我午餐吃油飯. --. 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.205.121.

推噓1(1推 0噓 1→)留言2則,0人參與, 1年前最新作者dont (dont)時間1年前 (2024/12/13 09:09), 編輯資訊
0
0
0
內容預覽:
2593. Find Score of an Array After Marking All Elements. ## 思路. 建(num, idx) 的min heap. 每次pop檢查idx有沒有mark過, 沒有就+score並mark. ## Code. ```python. class S
(還有388個字)

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者DJYOMIYAHINA (通通打死)時間1年前 (2024/12/12 22:40), 編輯資訊
0
0
0
內容預覽:
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,
(還有52個字)

推噓1(1推 0噓 2→)留言3則,0人參與, 1年前最新作者dont (dont)時間1年前 (2024/12/12 18:59), 編輯資訊
0
0
0
內容預覽:
2558. Take Gifts From the Richest Pile. ## 思路. max heap. ## Code. ```python. class Solution:. def pickGifts(self, gifts: List[int], k: int) -> int:. m
(還有597個字)