package leetcode;

/**
 * https://leetcode.com/problems/smallest-string-starting-from-leaf/
 */
public class Problem988 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    public String smallestFromLeaf(TreeNode root) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem988 prob = new Problem988();
    }
}

@@ -343,16 +343,32 @@
     
-// TODO%0A
+if (root == null) %7B%0A    
     
@@ -382,107 +382,522 @@
 urn 
-null;%0A
+%22%22;%0A   
     
+ 
 %7D
-%0A
 %0A    
-public static void main(String%5B%5D args) %7B%0A        Problem988 prob = new Problem988(
+    String left = smallestFromLeaf(root.left);%0A        String right = smallestFromLeaf(root.right);%0A        String val = %22%22;%0A        if (!left.isEmpty()) %7B%0A            val = left;%0A        %7D else if (!right.isEmpty()) %7B%0A            val = right;%0A        %7D%0A        if (!left.isEmpty() && !right.isEmpty()) %7B%0A            if (left.compareTo(right) %3C= 0) %7B%0A                val = left;%0A            %7D else %7B%0A                val = right;%0A            %7D%0A        %7D%0A        return val + (char) (root.val + 'a'
 );%0A 

Solve probem 988