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

推噓2(2推 0噓 2→)留言4則,0人參與, 1年前最新作者DJYOMIYAHINA (通通打死)時間1年前 (2024/11/13 23:10), 1年前編輯資訊
0
0
0
內容預覽:
用一堆bisect function可以過. 但其實insort是O(N) 所以這樣是O(N^2). 想當然是墊底. 看答案. 原來先sort+two pointer也行. 我好笨. def countFairPairs(self, nums: List[int], lower: int, uppe
(還有236個字)

推噓0(0推 0噓 1→)留言1則,0人參與, 1年前最新作者dont (dont)時間1年前 (2024/11/13 19:25), 編輯資訊
0
0
0
內容預覽:
2563. Count the Number of Fair Pairs. ## 思路. 任兩數相加介於lower, upper之間. 先排序. 用Two pointer分別計算小於等於upper跟lower-1 Pair個數並相減. ## Code. ```. class Solution:. d
(還有408個字)

推噓1(1推 0噓 0→)留言1則,0人參與, 1年前最新作者JIWP (神楽めあ的錢包)時間1年前 (2024/11/12 23:28), 編輯資訊
0
0
0
內容預覽:
2070. Most Beautiful Item for Each Query. 給一個二為矩陣 items,其中items[i]=[price_i,beauty_i]. 再給一個queries矩陣. 請回傳一個answer矩陣. 其中answer[i]是items矩陣裡price小等於queri
(還有1396個字)

推噓1(1推 0噓 0→)留言1則,0人參與, 1年前最新作者JerryChungYC (JerryChung)時間1年前 (2024/11/12 19:33), 編輯資訊
0
0
1
內容預覽:
https://leetcode.com/problems/most-beautiful-item-for-each-query. 2070. Most Beautiful Item for Each Query. 給一個 2D 整數數組 items 其中 items[i] = [price_i,
(還有755個字)

推噓0(0推 0噓 1→)留言1則,0人參與, 1年前最新作者dont (dont)時間1年前 (2024/11/12 19:04), 編輯資訊
0
0
0
內容預覽:
2070. Most Beautiful Item for Each Query. ## 思路. 1. 對items排序. 2. 更新items的beauty (紀錄目前為止的max beauty). 3. Binary Search. ## Code. ```python. class Solut
(還有601個字)