leetcode-145-二叉树的后序遍历

70 阅读1分钟

image.png leetcode

解题思路

  • 使用递归遍历
var postorderTraversal = function(root, res = []) {
   if(!root)return res
   postorderTraversal(root.left, res)
   postorderTraversal(root.right, res)
   res.push(root.val)
   return res
}