1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/求和路径 [paths-with-sum-lcci].html
2022-03-29 12:43:11 +08:00

25 lines
797 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定一棵二叉树,其中每个节点都含有一个整数数值(该值或正或负)。设计一个算法,打印节点数值总和等于某个给定值的所有路径的数量。注意,路径不一定非得从二叉树的根节点或叶节点开始或结束,但是其方向必须向下(只能从父节点指向子节点方向)。</p>
<p><strong>示例:</strong><br>
给定如下二叉树,以及目标和&nbsp;<code>sum = 22</code></p>
<pre> 5
/ \
4 8
/ / \
11 13 4
/ \ / \
7 2 5 1
</pre>
<p>返回:</p>
<pre>3
<strong>解释:</strong>和为 22&nbsp;的路径有:[5,4,11,2], [5,8,4,5], [4,11,7]</pre>
<p>提示:</p>
<ul>
<li><code>节点总数 &lt;= 10000</code></li>
</ul>