JavaScript刷LeetCode -- 94. Binary Tree Inorder Traversal【Medium】

一、题目

  Given a binary tree, return the inorder traversal of its nodes’ values.

二、题目大意

  二叉树的中序遍历。

三、解题思路

  递归

四、代码实现

const inorderTraversal = root => {
  const ans = []
  help(root)
  return ans
  function help (root) {
    if (!root) {
      return
    }
    help(root.left)
    ans.push(root.val)
    help(root.right)
  }
}

  如果本文对您有帮助,欢迎关注微信公众号,为您推送更多内容,ε=ε=ε=┏(゜ロ゜;)┛。

猜你喜欢

转载自blog.csdn.net/dai_qingyun/article/details/85222277