![](https://img.haomeiwen.com/i12464670/4a074914a38e98f2.png)
思路:
![](https://img.haomeiwen.com/i12464670/ec891009f5f35293.png)
引申:
打印二叉树,中的每一个 深度优先 的路径:10-5-4,10-5-7,10-12
当root.left为空,root.right为空时,说明走到了头,加入result列表。dfs递归终止条件是,加入result列表
![](https://img.haomeiwen.com/i12464670/63f8926981476d64.png)
![](https://img.haomeiwen.com/i12464670/15943c053ece98ed.png)
原题目的答案:
![](https://img.haomeiwen.com/i12464670/5ae5a2fec0d82818.png)
思路:
引申:
打印二叉树,中的每一个 深度优先 的路径:10-5-4,10-5-7,10-12
当root.left为空,root.right为空时,说明走到了头,加入result列表。dfs递归终止条件是,加入result列表
原题目的答案:
本文标题:【树】二叉树中节点值和为某一数
本文链接:https://www.haomeiwen.com/subject/nbjouftx.html
网友评论