116. Populating Next Right Pointers in Each Node - Medium
前往題目
想法
- 用
Breadth-First Search
思路
Breadth-First Search
- 搜尋的時候建立
next
指針,因為每次循環都剛好是整層,疊代整層的時候順便把指針也設定好了
Code
一陣子沒寫BFS
了,但還記得!
另外NeetCode
給的解法更加的簡潔
116. Populating Next Right Pointers in Each Node - Medium
https://f88083.github.io/2024/09/18/116-Populating-Next-Right-Pointers-in-Each-Node-Medium/