Grant apparently wrote ever word of his memoirs with great encouragement from his publisher, Mark Twain. The book GRANT AND TWAIN by Rick Perry describes the friendship that developed between these two men and how Twain and his publishing company won the rights to publish Grant's autobiography. Badeau and Grant had a falling out in the process.
One correction on my post: the name of the author of the book GRANT AND TWAIN is Mark Perry. Not Rick Perry.