2-pointer

Sep
05
刷題可以像打電動,薩爾達傳說教我的刷題技巧

刷題可以像打電動,薩爾達傳說教我的刷題技巧

🤔你在刷題準備面試嗎?🤔 是不是刷一題就花了整整一個晚上? 為什麼有人可以全職上班 幾個月就刷完三百題? 🎲最近我在沈迷電動「薩爾達傳說」🎲 打怪沒什麼興趣,都交給我室友打 但我超級喜歡解謎 在薩爾達傳說裡 主角林克有八大技能 只要排列組合運用技能 加上周遭的物品和道具 通常就能解謎通關,超級有成就感! 而且,從薩爾達的解謎策略,我竟然悟出刷題訣竅!🤩 🔍每個道具和週遭物品,都有用途!
3 min read
Sep
01
Leetcode刷題日記 - #80. Remove Duplicates from Sorted Array ii

Leetcode刷題日記 - #80. Remove Duplicates from Sorted Array ii

題目請自行上Leetcode閱讀:https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ Sorted Array:只要講到Sorted Array就要知道這跟問題應該跟2 pointer有關聯 Return Value, k:這種題目的關鍵就是k,k指向的就是到目前為止沒有出現超過兩次 這題有點難想,雖然是#26的變化形,整個沒辦法一下子就想出解法
2 min read
Sep
01
Leetcode刷題日記 - #27 Remove Elements

Leetcode刷題日記 - #27 Remove Elements

題目請自行上Leetcode閱讀:https://leetcode.com/problems/remove-element/ 1. Return Value, k:這題跟#26 Remove Duplicates from Sorted Array是差不多的,關鍵就是到k為指,你沒有val的Array的尾。 做法也是一樣的,
1 min read
Aug
15
Leetcode刷題日記 - #26 Remove Duplicates from Sorted Array

Leetcode刷題日記 - #26 Remove Duplicates from Sorted Array

題目請自行上Leetcode閱讀:https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 1. Sorted Array:只要講到Sorted Array就知道這跟問題應該跟2 pointer有關聯 2. Return Value, k:題目要求要把Array當中重複的數字移除,不直接宣告一個新的Array,在原本的Array裡面做,最後回傳移除後的Array長度k,
2 min read
Aug
14
Leetcode刷題日記 - #88 Merge Sorted Array

Leetcode刷題日記 - #88 Merge Sorted Array

1. Sorted Array:大多數的時候,解題的關鍵在,是不是能夠在看到題目的當下,迅速辨識「這題在問什麼」。看到“Sorted” Array的時候,大多數都在問2 pointer 2. 2 pointer的題目,要用畫圖去想比較容易一些,不然index數字很容易讓腦子很混亂,先自己用視覺的方式跑過一遍再寫解法,面試官也比較容易懂。
3 min read