You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.</p>
<p><strong>Note:</strong> A leaf is a node with no children.</p>
<p><strong>Example:</strong></p>
<p>Given the below binary tree and <code>sum = 22</code>,</p>
<pre>
<strong>5</strong>
<strong>/</strong> \
<strong>4</strong> 8
<strong>/</strong> / \
<strong>11</strong> 13 4
/ <strong>\</strong> \
7 <strong>2</strong> 1
</pre>
<p>return true, as there exist a root-to-leaf path <code>5->4->11->2</code> which sum is 22.</p>