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