command
Version:
v0.0.0-...-a94f1ba
Opens a new window with list of versions in this module.
Published: Jan 22, 2024
License: BSD-3-Clause
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
思路
DFS 深度优先搜索
每个节点只能保留一个硬币,不管是移入还是移出,都需要移动当前硬币 - 1
次,从最深处开始移动,每次移动的数都累计在父节点上,父节点需要移动的次数是自身硬币数 + 左边移动的硬币数 + 右边移动的硬币数 - 1
。
Documentation
¶
*
- Definition for a binary tree node.
- type TreeNode struct {
- Val int
- Left *TreeNode
- Right *TreeNode
- }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.