We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
例如: 给定二叉树 [3,9,20,null,null,15,7], 返回其自底向上的层次遍历为:
/** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * this.left = this.right = null; * } */ /** * @param {TreeNode} root * @return {number[][]} */ var levelOrderBottom = function(root) { if(!root||root.val===undefined){ return [] } var arr = new Array(); var nodes = new Array() nodes.push(root) while(nodes.length){ let arr2 = new Array(); let arr3 = new Array() for(var attr in nodes){ arr2.push( nodes[attr].val ) nodes[attr].left && arr3.push(nodes[attr].left); nodes[attr].right && arr3.push(nodes[attr].right) } nodes = arr3 arr.unshift( arr2 ) } return arr };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
给定一个二叉树,返回其节点值自底向上的层次遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历)
例如:
给定二叉树 [3,9,20,null,null,15,7],
返回其自底向上的层次遍历为:
The text was updated successfully, but these errors were encountered: