Gary Lai

1302. Deepest Leaves Sum

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

938. Range Sum of BST

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

480. Sliding Window Median

480. Sliding Window Median 這個題目是一個移動窗口以及找尋中位數的題目,難度為 hard ,這個題目難的地方在於: 1. 每次移動窗口的時候,

1962. Remove Stones to Minimize the Total

1962. Remove Stones to Minimize the Total class Solution: def

270. Closest Binary Search Tree Value

270. Closest Binary Search Tree Value 這個題目被標記為簡單是因為這個題目存在著一個簡單的解法,但是這個題目存在一個更優解,這個更優解就很難想得到。 簡單的解法是,

2368. Reachable Nodes With Restrictions

2368. Reachable Nodes With Restrictions class Solution: def reachableNodes(self,

695. Max Area of Island

695. Max Area of Island class Solution: def maxAreaOfIsland(self,

103. Binary Tree Zigzag Level Order Traversal

103. Binary Tree Zigzag Level Order Traversal # Definition for a

515. Find Largest Value in Each Tree Row

515. Find Largest Value in Each Tree Row 題目要熟悉 BFS

1026. Maximum Difference Between Node and Ancestor

1026. Maximum Difference Between Node and Ancestor 這題要找的是 「某個節點與它的祖先節點之間的差異最大值」。節點的選擇可以是樹中的任何一點,