Re: [閒聊] 每日leetcode

作者: Rushia (みけねこ的鼻屎)   2024-04-16 09:16:35
https://leetcode.com/problems/add-one-row-to-tree
623. Add One Row to Tree
給你一個二元樹,請在深度為depth的位置插入一列值為val的節點。
思路:
1.用 bfs 算深度找到 depth - 1 的位置,直接插入。
2.depth == 1 是 corner case 要額外處理。
py code:
作者: oinishere (是oin捏)   2024-04-16 09:19:00
大師

Links booklink

Contact Us: admin [ a t ] ucptt.com