LeetCode 筆記 - 1302. Deepest Leaves Sum
題目在此 1302. Deepest Leaves Sum
給定一個 Binary Tree,計算出最深 node 的總和

解題思維
這題的關鍵就是找出同一層的 node 有哪些
在這裡 Breadth-First Search 剛好可以幫上我們的忙
透過搜索的順序,最終我們就可以知道 最底層的 node 有哪些
程式碼
1 | # Definition for a binary tree node. |
題目在此 1302. Deepest Leaves Sum
給定一個 Binary Tree,計算出最深 node 的總和
這題的關鍵就是找出同一層的 node 有哪些
在這裡 Breadth-First Search 剛好可以幫上我們的忙
透過搜索的順序,最終我們就可以知道 最底層的 node 有哪些
1 | # Definition for a binary tree node. |