175. 翻转二叉树
2018-03-12 21:10
190 查看
175. 翻转二叉树
描述笔记
数据
评测
翻转一棵二叉树您在真实的面试中是否遇到过这个题? Yes样例
1 1 / \ / \ 2 3 => 3 2 / \ 4 4
/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this->left = this->right = NULL; * } * } */ class Solution { public: /** * @param root: a TreeNode, the root of the binary tree * @return: nothing */ void invertBinaryTree(TreeNode * root) { // write your code here TreeNode *temp = root->left; root->left = root->right; root->right = temp; if(root->left!=NULL)invertBinaryTree(root->left); if(root->right!=NULL)invertBinaryTree(root->right); } };
相关文章推荐
- LintCode - 175.翻转二叉树
- 175.翻转二叉树
- [LintCode]175.翻转二叉树
- 【LintCode 简单】175. 翻转二叉树
- Lintcode 175. 翻转二叉树
- 175. 翻转二叉树--java
- LintCode --invert-binary-tree(翻转二叉树)
- 二叉树翻转
- LeetCode Invert Binary Tree 翻转二叉树
- [数据结构][Leetcode]翻转二叉树
- 175-翻转二叉树
- 翻转二叉树
- 翻转二叉树(C++)
- 二叉树的高度 、销毁、链表的翻转(k为一组、n-m 之间)两种实现、
- Lintcode---翻转二叉树
- Tree Mirror output(二叉树翻转)
- 翻转二叉树-LintCode
- 翻转二叉树
- lintcode翻转二叉树
- 将一个二叉树左右翻转(Java 版)