討論串[閒聊] 每日LeetCode
共 719 篇文章

推噓3(3推 0噓 0→)留言3則,0人參與, 2年前最新作者umi0912umi (大空スバル的香腸)時間2年前 (2023/02/08 18:21), 編輯資訊
0
0
0
內容預覽:
class Solution:. def jump(self, nums: List[int]) -> int:. count, now_pos = 0, 0. while now_pos < len(nums)-1 :. jump_step = nums[now_pos]. max_length
(還有431個字)

推噓2(2推 0噓 2→)留言4則,0人參與, 2年前最新作者Rushia (みけねこ的鼻屎)時間2年前 (2023/02/08 09:32), 編輯資訊
0
1
0
內容預覽:
45. Jump Game II. 給你一個陣列nums,nums[i]表示從這個點可以往後移動幾格,求出從第0格開始,最少. 跳幾格可以跳到陣列尾端(題目保證一定可以到陣列尾端)。. Example:. Input: nums = [2,3,1,1,4]. Output: 2. Explanati
(還有723個字)

推噓1(1推 0噓 1→)留言2則,0人參與, 2年前最新作者fxfxxxfxx (愛麗絲)時間2年前 (2023/02/07 13:57), 編輯資訊
0
0
0
內容預覽:
904. Fruit Into Baskets. 題目就不附了,標準的 sliding window. class Solution {. public:. int totalFruit(vector<int>& fruits) {. unordered_map<int, int> M;. int
(還有1156個字)

推噓1(1推 0噓 1→)留言2則,0人參與, 2年前最新作者Rushia (みけねこ的鼻屎)時間2年前 (2023/02/07 09:57), 2年前編輯資訊
0
1
0
內容預覽:
904. Fruit Into Baskets. 給你一個陣列fruits表示一整列的水果樹,fruits[i]表示某一種類的水果,求出在滿. 足下列規則時,最多可以得到幾個水果?. * 你有兩個籃子,每個籃子只能裝一種水果,籃子的空間是無限大. * 你每次只能從水果樹中拿一顆水果,你可以從某個樹開
(還有1246個字)

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者abcd991276 (QQ)時間2年前 (2023/02/06 15:35), 編輯資訊
0
1
0
內容預覽:
引述《Rushia》之銘言. 把題目給的建兩個小的vector. 前半跟後半. 然後迴圈一次一次在要回傳的ans 放入前半一個後半一個. class Solution {. public:. vector<int> shuffle(vector<int>& nums, int n) {. vec
(還有302個字)