|
8 | 8 | importjava.util.List;
|
9 | 9 | importjava.util.Map;
|
10 | 10 |
|
11 |
| -/** |
12 |
| - * 988. Smallest String Starting From Leaf |
13 |
| - * |
14 |
| - * Given the root of a binary tree, each node has a value from 0 to 25 representing the letters 'a' to 'z': |
15 |
| - * a value of 0 represents 'a', a value of 1 represents 'b', and so on. |
16 |
| - * Find the lexicographically smallest string that starts at a leaf of this tree and ends at the root. |
17 |
| - * (As a reminder, any shorter prefix of a string is lexicographically smaller: for example, "ab" is lexicographically smaller than "aba". |
18 |
| - * A leaf of a node is a node that has no children.) |
19 |
| - * |
20 |
| - * Example 1: |
21 |
| - * Input: [0,1,2,3,4,3,4] |
22 |
| - * Output: "dba" |
23 |
| - * |
24 |
| - * Example 2: |
25 |
| - * Input: [25,1,3,1,3,0,2] |
26 |
| - * Output: "adz" |
27 |
| - * |
28 |
| - * Example 3: |
29 |
| - * Input: [2,2,1,null,1,0,null,0] |
30 |
| - * Output: "abc" |
31 |
| - * |
32 |
| - * Note: |
33 |
| - * The number of nodes in the given tree will be between 1 and 8500. |
34 |
| - * Each node in the tree will have a value between 0 and 25. |
35 |
| - * */ |
36 | 11 | publicclass_988 {
|
37 | 12 | publicstaticclassSolution1 {
|
38 | 13 | publicStringsmallestFromLeaf(TreeNoderoot) {
|
|