public List<String> binaryTreePaths2(TreeNode root) {
        List<String> list = new ArrayList<>();
        if (root == null) {
            return list;
        }
        StringBuilder sb = new StringBuilder();
        sb.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));

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