PIXNET Logo登入

Sofie 舒霏的部落格

跳到主文

歡迎光臨Sofie 舒霏 *¯︶¯*在痞客邦的小天地 會不定期分享英文學習/進修/西洋歌曲 & 電腦科學等主題!

部落格全站分類:偶像明星

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 4月 01 週四 202122:28
  • Leetcode 筆記-reverse string 翻轉字串系列

image因為這系列做起來很快,所以就索性一次貼在一篇文了!
PART 1-344. Reverse String (Easy)
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(203)

  • 個人分類:Leetcode
▲top
  • 3月 31 週三 202123:59
  • Leetcode 筆記-7. reverse integer (常見面試問題)

image今天要來解的題目是 Leetcode-7. Reverse Integer,難度為 Easy,
而我所使用的語言是 python3
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(55)

  • 個人分類:Leetcode
▲top
  • 3月 30 週二 202115:21
  • Leetcode 筆記 - 152. Maximum Product Subarray

image今天要來解的題目是 Leetcode-152. Maximum Product Subarray,難度為 Medium,
而我所使用的語言是 python3
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(967)

  • 個人分類:Leetcode
▲top
  • 3月 30 週二 202114:45
  • Leetcode - Kadane's Algorithm 解「最大子數列問題」

imageKadane's Algorithm for solving Maximum Subarray
如果你已經知道某 array A 從 「頭」 加到「第 i 個數字」的最大值,
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(1,255)

  • 個人分類:Leetcode
▲top
  • 3月 28 週日 202123:23
  • Leetcode 筆記-238. Product of Array Except Self

黑人問號圖的主角到底是誰?其實他的背景可大有來頭! | 網路人氣話題| DailyView 網路溫度計今天要來解的題目是 Leetcode-238. Product of Array Except Self,難度為 Medium,
而我所使用的語言是 python3
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(445)

  • 個人分類:Leetcode
▲top
  • 3月 08 週一 202116:30
  • Hack(?) a website | 台灣總統(小英)變 Elsa?

image今天來做一點有趣的實作吧!
 
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(10)

  • 個人分類:網路服務程式設計 web programming
▲top
  • 3月 06 週六 202110:27
  • 那些你沒看到的細節 Queen's Gambit《后翼棄兵》| 爆紅 Netflix 美劇影評

Queen's Gambit 已經紅了一陣子了,
或許你還在觀望,「關於西洋棋的影集?」聽起來不是特別有趣,
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(1,002)

  • 個人分類:英文歌曲/追星/電影
▲top
  • 3月 05 週五 202121:26
  • Leetcode 筆記-42. Trapping Rain Water

image今天要來解的題目是 Leetcode-42. Trapping Rain Water ,難度為 Hard,
而我所使用的語言是 python3
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(488)

  • 個人分類:Leetcode
▲top
  • 3月 05 週五 202113:00
  • Leetcode 筆記-142. Linked List Cycle II

image
今天要來解的題目是 Leetcode-142. Linked List Cycle II ,難度為中等,
而我所使用的語言是 python3
 
壹、理解題目
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is not passed as a parameter.
Notice that you should not modify the linked list.
簡單而言,就是
如果有 cycle:回傳 cycle 的起始點
如果沒有:回傳 None
 
其實這題是 141 的延伸題(如何判斷有沒有 cycle?)
在做這題之前,可以先點進這裡看 141 的解法喔!
同樣會使用到此演算法:Floyd's Tortoise and Hare (Cycle Detection)
 
貳、開始解題
解決 141 後,你應該就知道如何判斷是否有 cycle 了!
就是龜兔第二次相遇的時候,但
他們第二次相遇的 node 不一定會是 cycle 的起始點 (cycle head),
 
那麼 要如何找到 cycle head 呢?
在結束第一階段-讓兩者相遇之後,
讓 tortoise 回到原點,而 hare 每次只走一步 (just like tortoise),
直到兩者再次相遇,那個點就會是 cycle head!
 
Why?
所有的 case 都可以簡化成以下的圖
L 是起始點和 cycle head 的距離、x 是 cycle head 到第一次見面的距離、C 是整個 cycle 的長度
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(523)

  • 個人分類:Leetcode
▲top
  • 3月 04 週四 202113:49
  • Leetcode 筆記-141. Linked List Cycle

image今天要來解的題目是 Leetcode-141. Linked List Cycle,難度為易,
而我所使用的語言是 python3
(繼續閱讀...)
文章標籤

Sofie 舒霏 發表在 痞客邦 留言(0) 人氣(659)

  • 個人分類:Leetcode
▲top
123»

個人資訊

Sofie 舒霏
暱稱:
Sofie 舒霏
分類:
偶像明星
好友:
累積中
地區:

熱門文章

  • (193)泰勒絲男友 Let's meet her London boy !
  • (154)Taylor Swift - Gorgeous 歌曲分析
  • (329)你以為 Taylor Swift 只會寫情歌?那你該聽聽這首 The Man | 兩性平權
  • (8,282)想練英文又懶得追劇?不藏私國外 youtuber 推薦!
  • (413)Taylor Swift - Me 歌曲 & MV 彩蛋分析
  • (1,875)Leetcode 筆記-208. Implement Trie (Prefix Tree) | 什麼是字首樹?
  • (1,336)Leetcode 筆記-287. Find the Duplicate Number
  • (1,524)sftp 常用指令大全 | 駭客都馬用 terminal
  • (1,155)爺爺的證明題:上帝存在嗎? | 科普書籍觀後感
  • (952)數學女孩:費馬最後定理 | 科普書籍觀後感

文章分類

  • 網路服務程式設計 web programming (1)
  • 課外書觀後心得 (2)
  • 終端機 | Terminal (2)
  • GRE/TOEFL (0)
  • Leetcode (11)
  • 關乎學習 (4)
  • python (1)
  • 英文歌曲/追星/電影 (6)
  • 未分類文章 (1)

最新文章

  • Leetcode 筆記-reverse string 翻轉字串系列
  • Leetcode 筆記-7. reverse integer (常見面試問題)
  • Leetcode 筆記 - 152. Maximum Product Subarray
  • Leetcode - Kadane's Algorithm 解「最大子數列問題」
  • Leetcode 筆記-238. Product of Array Except Self
  • Hack(?) a website | 台灣總統(小英)變 Elsa?
  • 那些你沒看到的細節 Queen's Gambit《后翼棄兵》| 爆紅 Netflix 美劇影評
  • Leetcode 筆記-42. Trapping Rain Water
  • Leetcode 筆記-142. Linked List Cycle II
  • Leetcode 筆記-141. Linked List Cycle

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣:

pixGoogleAdsense1

pixGoogleAdsense2