LeetCode

739. Daily Temperatures

739. Daily Temperatures 題目給定一個陣列,裡面是一段時間日子的每日溫度,我們要找出每一天,再經過幾天後,就會遇到一個比較溫暖的天氣。 這個題目是一個單調棧 Monotonic

496. Next Greater Element I

496. Next Greater Element I 這一題是 Monotonic 的題目,但是他的變形其實滿難的,會建議先從

346. Moving Average from Data Stream

346. Moving Average from Data Stream class MovingAverage: def __init_

1544. Make The String Great

1544. Make The String Great class Solution: def makeGood(self,

71. Simplify Path

71. Simplify Path class Solution: def simplifyPath(self, path: str)

844. Backspace String Compare

844. Backspace String Compare class Solution: def backspaceCompare(self, s:

24. Swap Nodes in Pairs

24. Swap Nodes in Pairs 我一開始的想法比較單純,因為題目是要求奇數跟偶數的位置交換,所以我很直覺的寫了一個先把奇數位置的元素記錄起來,再把偶數元素記錄起來,最後再重新串起來。

336. Palindrome Pairs

336. Palindrome Pairs class Solution: def palindromePairs(self, words: List[

1302. Deepest Leaves Sum

1302. Deepest Leaves Sum 1. 把每一層的總和都記錄起來 # Definition for a binary

938. Range Sum of BST

938. Range Sum of BST 這個題目雖然是簡單,但應該只是實作簡單,真的寫起來不是這麼好想。 我的第一個想法是利用 BST