Skip to content
New issue

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

翻转二叉树 #414

Open
veneno-o opened this issue Jan 19, 2023 · 2 comments
Open

翻转二叉树 #414

veneno-o opened this issue Jan 19, 2023 · 2 comments

Comments

@veneno-o
Copy link
Contributor

No description provided.

@veneno-o
Copy link
Contributor Author

veneno-o commented Jan 19, 2023

  • 这道题目背后有一个让程序员心酸的故事,听说 Homebrew的作者Max Howell,就是因为没在白板上写出翻转二叉树,最后被Google拒绝了。

image

@veneno-o
Copy link
Contributor Author

function invertTree(root) {
    if(!root) return root;
    invertTree(root.left);
    invertTree(root.right);
    [root.left, root.right] = [root.right, root.left];
    return root;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant