Skip to content

Latest commit

 

History

History
15 lines (14 loc) · 339 Bytes

0145-二叉树的后序遍历.md

File metadata and controls

15 lines (14 loc) · 339 Bytes
var postorderTraversal = function(root) {
  const res = []
  postorderTraversalNode(root, (v) => res.push(v))
  return res
};

var postorderTraversalNode = function(node, callback) {
  if (node !== null) {
    postorderTraversalNode(node.left, callback)
    postorderTraversalNode(node.right, callback)
    callback(node.val)
  }
}