1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 11:08:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/二叉树的所有路径 [binary-tree-paths].html

28 lines
804 B
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<p>给你一个二叉树的根节点 <code>root</code> ,按 <strong>任意顺序</strong> ,返回所有从根节点到叶子节点的路径。</p>
<p><strong>叶子节点</strong> 是指没有子节点的节点。</p>
&nbsp;
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/03/12/paths-tree.jpg" style="width: 207px; height: 293px;" />
<pre>
<strong>输入:</strong>root = [1,2,3,null,5]
<strong>输出:</strong>["1-&gt;2-&gt;5","1-&gt;3"]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>root = [1]
<strong>输出:</strong>["1"]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>树中节点的数目在范围 <code>[1, 100]</code></li>
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
</ul>