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.
Tree: Postorder Traversal
Tree: Postorder Traversal
Sort by
recency
|
223 Discussions
|
Please Login in order to post a comment
Solution with Javascript:
function postOrder(root) { const stack = iterate(root)
console.log(stack.join(' ')) }
function iterate(root, stack = []) { if (root == null) { return }
iterate(root.left, stack) iterate(root.right, stack)
stack.push(root.data)
return stack } `
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions , feel free to give a star :) )
Here a Python Iterative:
simple java solution