Skip to content

Commit 010672b

Browse files
committed
Create README - LeetHub
1 parent ee6994e commit 010672b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

0112-path-sum/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2><a href="https://leetcode.com/problems/path-sum">112. Path Sum</a></h2><h3>Easy</h3><hr><p>Given the <code>root</code> of a binary tree and an integer <code>targetSum</code>, return <code>true</code> if the tree has a <strong>root-to-leaf</strong> path such that adding up all the values along the path equals <code>targetSum</code>.</p>
2+
3+
<p>A <strong>leaf</strong> is a node with no children.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
<img alt="" src="https://assets.leetcode.com/uploads/2021/01/18/pathsum1.jpg" style="width: 500px; height: 356px;" />
8+
<pre>
9+
<strong>Input:</strong> root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22
10+
<strong>Output:</strong> true
11+
<strong>Explanation:</strong> The root-to-leaf path with the target sum is shown.
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
<img alt="" src="https://assets.leetcode.com/uploads/2021/01/18/pathsum2.jpg" />
16+
<pre>
17+
<strong>Input:</strong> root = [1,2,3], targetSum = 5
18+
<strong>Output:</strong> false
19+
<strong>Explanation:</strong> There are two root-to-leaf paths in the tree:
20+
(1 --&gt; 2): The sum is 3.
21+
(1 --&gt; 3): The sum is 4.
22+
There is no root-to-leaf path with sum = 5.
23+
</pre>
24+
25+
<p><strong class="example">Example 3:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> root = [], targetSum = 0
29+
<strong>Output:</strong> false
30+
<strong>Explanation:</strong> Since the tree is empty, there are no root-to-leaf paths.
31+
</pre>
32+
33+
<p>&nbsp;</p>
34+
<p><strong>Constraints:</strong></p>
35+
36+
<ul>
37+
<li>The number of nodes in the tree is in the range <code>[0, 5000]</code>.</li>
38+
<li><code>-1000 &lt;= Node.val &lt;= 1000</code></li>
39+
<li><code>-1000 &lt;= targetSum &lt;= 1000</code></li>
40+
</ul>

0 commit comments

Comments
 (0)