@@ -0,0 +1,1264 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * https://leetcode.com/problems/binary-tree-paths/%0A */%0Apublic class Problem257 %7B%0A    public static class TreeNode %7B%0A        int val;%0A        TreeNode left;%0A        TreeNode right;%0A%0A        TreeNode(int x) %7B%0A            val = x;%0A        %7D%0A    %7D%0A%0A    public List%3CString%3E binaryTreePaths(TreeNode root) %7B%0A        List%3CString%3E paths = new ArrayList%3C%3E();%0A        if (root == null) %7B%0A            return paths;%0A        %7D%0A        binaryTreePaths(root, %22%22, paths);%0A        return paths;%0A    %7D%0A    %0A    private void binaryTreePaths(TreeNode node, String path, List%3CString%3E paths) %7B%0A        if (node == null) %7B%0A            paths.add(path);%0A            return;%0A        %7D%0A        String newPath = %22%22;%0A        if (path.isEmpty()) %7B%0A            newPath = Integer.toString(node.val);%0A        %7D else %7B%0A            newPath = path + %22-%3E%22 + Integer.toString(node.val);%0A        %7D%0A        if (node.left != null) %7B%0A            binaryTreePaths(node.left, newPath, paths);%0A        %7D%0A        if (node.right != null) %7B%0A            binaryTreePaths(node.right, newPath, paths);%0A        %7D%0A        if (node.left == null && node.right == null) %7B%0A            binaryTreePaths(node.left, newPath, paths);%0A        %7D%0A    %7D%0A%7D%0A

Solve problem 257