给定一个二叉树,返回它的中序 遍历。
示例:
输入: [1,null,2,3]
输出: [1,3,2]
中序排列:先输出左节点,在输出当前节点,最后输出右节点
var inorderTraversal = function(root) {
let list = []
if(!root) return []
run(root)
function run(root) {
const {left, right, val} = root
if (left) run(left)
list.push(val)
if (right) run(right)
}
return list
};