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
export {}; class TreeNode { constructor(val, left, right) { this.val = (val === undefined ? 0 : val); this.left = (left === undefined ? null : left); this.right = (right === undefined ? null : right); } } // LeetCode 二叉树生成器 BinaryTreeGenerator = (arr = [], i = 0) => { if(arr.length === 0 || i > arr.length - 1 || arr[i] === null) { return null; } const node = new TreeNode(arr[i]); // 先左后右, 依次遍历 node.left = BinaryTreeGenerator(arr, 2 * i + 1); node.right = BinaryTreeGenerator(arr, 2 * i + 2); return node; } /* BinaryTreeGenerator([3,9,20,null,null,15,7]); https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ */
https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg
https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
作者:xgqfrms 链接:https://www.cnblogs.com/xgqfrms/p/17081303.html 来源:https://www.cnblogs.com 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 ©xgqfrms 2012-2023 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问! 原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
js Binary Tree Generator / js 二叉树生成器
https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg
https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
作者:xgqfrms⚠️ !
链接:https://www.cnblogs.com/xgqfrms/p/17081303.html
来源:https://www.cnblogs.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
©xgqfrms 2012-2023
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究
The text was updated successfully, but these errors were encountered: