<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by 林天行 on Medium]]></title>
        <description><![CDATA[Stories by 林天行 on Medium]]></description>
        <link>https://medium.com/@A_8809?source=rss-1c82c888d6ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QqrPNi0nR3MHvK9I2MJz5w.jpeg</url>
            <title>Stories by 林天行 on Medium</title>
            <link>https://medium.com/@A_8809?source=rss-1c82c888d6ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 11:08:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@A_8809/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Leetcode 169 Majority Element 用Moore Voting實作]]></title>
            <link>https://medium.com/@A_8809/leetcode-169-majority-element-%E7%94%A8moore-voting%E5%AF%A6%E4%BD%9C-382c6d5eaac3?source=rss-1c82c888d6ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/382c6d5eaac3</guid>
            <dc:creator><![CDATA[林天行]]></dc:creator>
            <pubDate>Sun, 12 Sep 2021 06:19:01 GMT</pubDate>
            <atom:updated>2021-09-12T06:19:01.427Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*BoBGbXXgb9rYaWBtLq1JbQ.png" /><figcaption>題序</figcaption></figure><p>這題是給一個長度為n的陣列，要找出其中出現次數超過一半的元素。</p><p>老實說，這題我是看了解答有提到一個Moore voting的演算法才發現有這麼酷的做法，所以才特別想發一篇Medium來分享。</p><p>Moore voting algorithm: 把不同的兩兩消去，剩下的自然就會是要求的答案(因為題目有說答案會是出現次數超過一半的所以可以這樣做)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*M4niCImFkhL9E_Jrifi4Ag.png" /></figure><p>實作的部分是設定兩個變數major跟time，一開始major會是nums[0]，times(代表出現次數)是1，如果遇到相同元素則times++，代表出現次數多一，如果遇到不同元素的話times — ，出現次數減一，等times==0的時候就會把major設定成下一個元素，這樣一來就能實現Moore voting algorithm了!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=382c6d5eaac3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leetcode 70]]></title>
            <link>https://medium.com/@A_8809/leetcode-70-9d2a577f4860?source=rss-1c82c888d6ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d2a577f4860</guid>
            <dc:creator><![CDATA[林天行]]></dc:creator>
            <pubDate>Sun, 05 Sep 2021 09:50:24 GMT</pubDate>
            <atom:updated>2021-09-05T09:57:17.998Z</atom:updated>
            <content:encoded><![CDATA[<p>這題就是很經典的遞迴，問爬到第n階有幾種方法?</p><p>一開始就直接寫下去，判斷&lt;0,1,2的case之後其他的用遞迴</p><p>結果就吃TLE了XDD</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*LjVY_AAH-ZsONoqtVg4Ovw.png" /><figcaption>一開始直接遞迴</figcaption></figure><p>後來想到陳縕儂老師有講過遞迴有兩種方法，一個是top-down，一個是bottom-up，而通常bottom-up會是比較好的方法</p><p>想到這點，就建立一個array去存取對於每個n需要的步數，然後取值</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SlF8ZL5dE3ap5NBx_VjGQ.png" /><figcaption>建表 要用的時候直接取值</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d2a577f4860" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leetcode 刷題方法]]></title>
            <link>https://medium.com/@A_8809/leetcode-%E5%88%B7%E9%A1%8C%E6%96%B9%E6%B3%95-a71d55293cba?source=rss-1c82c888d6ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/a71d55293cba</guid>
            <dc:creator><![CDATA[林天行]]></dc:creator>
            <pubDate>Sat, 04 Sep 2021 18:58:13 GMT</pubDate>
            <atom:updated>2021-09-04T18:58:13.498Z</atom:updated>
            <content:encoded><![CDATA[<p>取自<a href="https://www.facebook.com/PivotSoftwareEngineer/?__cft__[0]=AZXAvqf1gB300i8A2BVNwW2ZErvNdd8qbFiW80_q4Ir6E4tKUadgLxGrzEGR1Wb2nPJUVlenn_HCyhiOb1RCsYnA3IqxOflTf3Gi5Zd5GR5VuoSY7PHmw9NV62R-T7yk9rU6WwYBl10FK9a4T2dmMggvK9TT7UHG97tRvRdGJIi6PX2u9Sc6w97t_x9UOOb1gvGqImS6A4v5-2fK0CmK6JKp&amp;__tn__=-UC%2CP-y-R">半路出家軟體工程師在矽谷</a></p><p>看到問題的時候， 我會先確保我了解題目的意思， 真正在面試的時候， 通常第一步也是和面試官確認我們自我的理解和面試官要問的是否一致， 不要花了時間才發現一開始的理解及假設是錯誤的。 我通常會立刻寫下題目給予的 input 有什麼、格式是什麼， desired output 又是什麼。</p><p>確認好 input &amp; output 後， 我會思考題目可以用什麼類型的資料結構或是演算法來解。 通常在面試的時候， 我會和面試官說明我可能會先就一個大概可行的方式來做解答， 如果他/她覺得沒有什麼問題的話， 我再做後續的優化。 在我開始有一些思路後， 我會先寫下 pseudo code， 就是先用英文來說明我的解法會是怎麼樣。 每個步驟和面試官確認都沒有問題後， 我才會正式寫 code 。</p><p>當然有些時候不論怎麼想都寫不出來， 如果是自己練習的時候，我大概在 15 分鐘後會開始看一些討論， 嘗試學習別人的思路， 但如果再花 10 分鐘還是解不出來的話， 才會參考別人的解法。 我看完別人的答案後， 還是會用自己的 code 再實現一次。 如果面試中卡住的話， 則是要儘快和面試官討論， 我會把我的理解， 可能的解法方式和面試官說， 同時也說明我的情況可能哪裏不是很確定， 讓面試官在適當的時候可以給予我提示。 一般來說， 公司都是希望有順利的面試經驗， 面試官也都願意在溝通正常下給予協助。</p><p>自己練習寫完之後， 我會再寫出解法的空間及時間複雜度 (Space &amp; Time Complexity) ， 通常面試也會詢問這個部分， 所以自己每個練習也要歸納一下。 如果我發現我的解法時間可能不是太好， 我會再嘗試看不同人的討論， 研究更優化的解法， 並再自己寫出不一樣的解法。 有些比較棘手的問題我可能會寫 2、3 個解法比較彼此的優缺點。</p><p>在之前準備面試的時候， 我有準備一本筆記本， 每次寫完問題之後， 我會用筆寫下我在哪一天寫了哪一個問題， 並且用很精簡的方式總結問題及解法。 隔天要做下一題之前， 我會先看一下前一天的問題， 嘗試回想我是否可以再次在頭腦中想出大致的解法。 如果還是不行的話， 再看我自己的總結並做上記號， 隔天會再做一次同樣的步驟，直到我可以順利複習出解題的邏輯思路。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a71d55293cba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>