Class Solution

java.lang.Object
g0201_0300.s0257_binary_tree_paths.Solution

public class Solution extends Object
257 - Binary Tree Paths.<p>Easy</p> <p>Given the <code>root</code> of a binary tree, return <em>all root-to-leaf paths in <strong>any order</strong></em>.</p> <p>A <strong>leaf</strong> is a node with no children.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/03/12/paths-tree.jpg" alt="" /></p> <p><strong>Input:</strong> root = [1,2,3,null,5]</p> <p><strong>Output:</strong> [&ldquo;1->2->5&rdquo;,&ldquo;1->3&rdquo;]</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> root = [1]</p> <p><strong>Output:</strong> [&ldquo;1&rdquo;]</p> <p><strong>Constraints:</strong></p> <ul> <li>The number of nodes in the tree is in the range <code>[1, 100]</code>.</li> <li><code>-100 <= Node.val <= 100</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details