Leetcode 暑期bb班
裂曲風紀 2022-5-29 20:25:00 not you

Ads

狗餅人 2022-5-29 20:43:47 已經好top了
:^(
:^(
:^(
:^(
南極灰熊 2022-5-29 22:01:17 咁即是練咗幾耐 一年?
見你2021去到2022中間大幅度攀升
陽炎座 2022-5-29 23:16:54 攞左幾題黎練
:^(
elon.musk. 2022-5-29 23:21:44
:^(
:^(
超勁
裂曲風紀 2022-5-30 00:12:41 2021年8月開始操,而家無操了,呢三個月希望同你地由0開始過,等多啲人克服leetcode
土撚 2022-5-30 06:53:35 巴打今日有無題目?
新手上路,偷偷地跟左幾日,宜家上水支持下。
用緊typescript,頭2日係咁錯data type 錯syntax,宜家好D了。

果位連燈巴打之前block左,佢似乎好鍾意搏人注意,唔洗理佢。
btw你真好勁
:^(
球皇哥利斯馬 2022-5-30 06:59:22 其實code呢d野係咪有數底會叻d
:^(
裂曲風紀 2022-5-30 07:00:54 多謝巴打支持
:^(

leetcode bb班周末休息,聽日開始返
聽日我地開一開新topic,繼續每日兩題
:^(
裂曲風紀 2022-5-30 07:01:45 STEM底都會有幫助
數學對leetcode幫助尤其高(problem solving)
希望呢度個pace係適合所有non-stem background嘅人跟到
:^(
三日一夜 2022-5-30 08:03:11 此回覆已被刪除

Ads

鮮奶紅茶 2022-5-30 08:06:01 有心人 強帖留名
我鐘意返工返學 2022-5-30 13:16:09 係香港可唔可以報?
Code4Food 2022-5-30 13:50:52 Google intern 係全球招聘。香港同學可以報美國同其他地方internship。注意summer intership要差不多提早一年申請。9月開學就好準備。
Code4Food 2022-5-30 14:04:27 between COVID 可能對intership有影響。你最好問返各大公司recruiter而家係乜情況。
BeautifulSoup 2022-5-30 14:11:06
:^(
裂曲風紀 2022-5-30 20:47:04 Day 4 Review:
https://leetcode.com/problems/find-players-with-zero-or-one-losses/
呢題應該都相對簡單,我地整兩個dictionary,一個dictionary係keep track住每個player贏過幾多場,另外一個dictionary係keep track住每個player輸過幾多場
answer[0]就係出現過係winner dictionary but not dictionary
answer[1]就係loser dictionary嘅value係1
最後兩個都 answer[0].sort(), answer[1].sort() 就ok

https://leetcode.com/problems/word-subsets/
呢題比較難,做一個Time Limit Exceeded 示範:
:^(

我地如果每一隻word1都要compare曬每一隻word2,就要做len(words1) * len(words2) comparison,會太慢
leetcode medium開始就要慢慢做一啲observation,呢題你要observe到我地只需要知道每一個英文字母係words2嘅每一隻字最多出現幾多次
例如 ["picnic", "ice"] ,picnic入面 'i' 出現左兩次, ice入面個'i'出現左一次,如果一個字符合picnic 出現兩次 i,咁佢一定會符合ice出現一次i,同樣地c都係,要符合條件一定要有最少兩個c (picnic)
所以要符合條件就要有 p : 1, i : 2, c : 2, n: 1, e: 1
答案你可以睇discussion
靜靜打J好無 2022-5-30 20:47:44 此回覆已被刪除
裂曲風紀 2022-5-30 20:53:53 Day 5: Heap

做leetcode時,你只需要知道heap嘅第一個數係minimum就ok
主要有兩個operation:
heappush(my_heap, new_value): 放新嘅數入heap
heappop(my_heap): remove最細嘅數出heap
兩個operation都係 log(N) time
python嘅heap by default係min heap,所以你要用max heap嘅話就要用負數

https://leetcode.com/problems/last-stone-weight/
最簡單嘅heap題例子
:^(


今日你可以試下呢題
https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/

如果你想睇下heap真係點work:
https://www.youtube.com/watch?v=AE5I0xACpZs
裂曲風紀 2022-5-30 20:56:31
:^(
程式猿 2022-5-30 21:01:17 有冇 rust 手足
:^(

Ads

靜靜打J好無 2022-5-30 21:09:41 此回覆已被刪除
靜靜打J好無 2022-5-30 21:27:02 此回覆已被刪除
靜靜打J好無 2022-5-30 21:28:56 此回覆已被刪除
裂曲風紀 2022-5-30 21:32:26 最勤力係你
:^(