void go(List<String> list, TreeNode root, StringBuilder sb) {
        if (root == null) {
            return;
        }

        sb.append("->").append(root.val);

        if (root.left == null && root.right == null) {
            list.add(sb.toString());
        }
        go(list, root.left, new StringBuilder(sb));
        go(list, root.right, new StringBuilder(sb));

    }
This is recursive solution with StringBuilder
src/problems/easy/BinaryTreePaths.java