You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var inorderTraversal = function(root) {
let list = []
function inorderTraversalNode(node){
if(node){
inorderTraversalNode(node.left)
list.push(node.val)
inorderTraversalNode(node.right)
}
}
inorderTraversalNode(root)
return list
};
Activity
xuanweiH commentedon May 12, 2020
7777sea commentedon May 12, 2020
luweiCN commentedon May 12, 2020
plane-hjh commentedon May 12, 2020
中序遍历
中序遍历:先访问左节点,再访问中节点,最后访问右节点递归版本
迭代版本
sisterAn commentedon May 12, 2020
递归实现
迭代实现
进一步简化:
复杂度分析:
空间复杂度:O(n)
时间复杂度:O(n)
leetcode
whitesky1225 commentedon May 18, 2020
我就来个最简单的递归版本吧。。