We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
There are many ways to do it. None of them result in pretty code. One way is to use a StringBuffer and save the output into the StringBuffer instead of printing the output immediatelly. Once the StringBuilder has the entire output, you can delete the last space and print the StringBuffer.
Tree: Postorder Traversal
You are viewing a single comment's thread. Return to all comments →
There are many ways to do it. None of them result in pretty code. One way is to use a StringBuffer and save the output into the StringBuffer instead of printing the output immediatelly. Once the StringBuilder has the entire output, you can delete the last space and print the StringBuffer.
HackerRank solutions.