Skip to content

Latest commit

 

History

History
15 lines (14 loc) · 329 Bytes

0094-二叉树的中序遍历.md

File metadata and controls

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

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