[2016/11/17]翻转二叉树
2016-11-18 13:29
155 查看
Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.
内心复杂地做完了这道带有传奇色彩的题。。
代码如下:
struct TreeNode* invertTree(struct TreeNode* root) { struct TreeNode* p; if(!root) return NULL; else{ p = root -> left; root -> left = root -> right; root -> right = p; } invertTree(root -> left); invertTree(root -> right); return root; }
相关文章推荐
- [LintCode] Invert Binary Tree 翻转二叉树
- lintcode——翻转二叉树
- lintcode 翻转二叉树
- 翻转二叉树
- 翻转二叉树
- lintcode ----翻转二叉树
- 题目:翻转二叉树
- Invert Binary Tree(翻转二叉树)
- LintCode--翻转二叉树(非递归)
- 翻转二叉树
- 第五章 树和二叉树翻转学习任务
- 算法之:翻转二叉树
- 学习日志---线索二叉树和翻转二叉树
- 翻转二叉树
- Invert a binary tree 翻转一棵二叉树
- LeetCode 226 Invert Binary Tree(翻转二叉树)
- 翻转二叉树
- 悲剧!Homebrew 的作者被 Google 拒啦,因为他不会翻转二叉树(转自V2EX)
- leetcode 226 Invert Binary Tree 翻转二叉树
- [LintCode] 翻转二叉树