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
出处 LeetCode 算法第144题 给定一个二叉树,返回它的 前序 遍历。 示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,2,3]
出处 LeetCode 算法第144题
给定一个二叉树,返回它的 前序 遍历。
示例:
输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,2,3]
递归遍历
/** * @param {TreeNode} root * @return {number[]} */ function helper(root, res) { res.push(root.val); if (root.left) { helper(root.left, res); } if (root.right) { helper(root.right, res); } } var preorderTraversal = function (root) { if (!root) return null; var res = []; helper(root, res); return res; };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
习题
思路
递归遍历
解答
The text was updated successfully, but these errors were encountered: