Class Solution
java.lang.Object
g0901_1000.s0988_smallest_string_starting_from_leaf.Solution
988 - Smallest String Starting From Leaf.<p>Medium</p>
<p>You are given the <code>root</code> of a binary tree where each node has a value in the range <code>[0, 25]</code> representing the letters <code>'a'</code> to <code>'z'</code>.</p>
<p>Return <em>the <strong>lexicographically smallest</strong> string that starts at a leaf of this tree and ends at the root</em>.</p>
<p>As a reminder, any shorter prefix of a string is <strong>lexicographically smaller</strong>.</p>
<ul>
<li>For example, <code>"ab"</code> is lexicographically smaller than <code>"aba"</code>.</li>
</ul>
<p>A leaf of a node is a node that has no children.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2019/01/30/tree1.png" alt="" /></p>
<p><strong>Input:</strong> root = [0,1,2,3,4,3,4]</p>
<p><strong>Output:</strong> “dba”</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2019/01/30/tree2.png" alt="" /></p>
<p><strong>Input:</strong> root = [25,1,3,1,3,0,2]</p>
<p><strong>Output:</strong> “adz”</p>
<p><strong>Example 3:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2019/02/01/tree3.png" alt="" /></p>
<p><strong>Input:</strong> root = [2,2,1,null,1,0,null,0]</p>
<p><strong>Output:</strong> “abc”</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the tree is in the range <code>[1, 8500]</code>.</li>
<li><code>0 <= Node.val <= 25</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
smallestFromLeaf
-