struct TreeNode* invertTree(struct TreeNode* root)
{ if ( NULL == root )
{
return NULL;
} if ( NULL == root->left && NULL == root->right )
{
//叶子节点
return root;
} //交换左右子节点
struct TreeNode * pTreeNodeTmp = root->left; root->left = root->right;
root->right = pTreeNodeTmp; invertTree(root->left);
invertTree(root->right); return root;
}

LeetCode —— Invert Binary Tree的更多相关文章

  1. LeetCode—— Invert Binary Tree

    LeetCode-- Invert Binary Tree Question invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 ...

  2. [LeetCode] Invert Binary Tree 翻转二叉树

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem wa ...

  3. LeetCode——Invert Binary Tree

    Description: Invert a binary tree. 4    /    \  2      7 /  \    /   \1   3   6   9 to 4 / \ 7 2 / \ ...

  4. LeetCode: Invert Binary Tree

    /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * Tre ...

  5. LeetCode Invert Binary Tree 反转二叉树

    思路:递归解决,在返回root前保证该点的两个孩子已经互换了.注意可能给一个Null. C++ /** * Definition for a binary tree node. * struct Tr ...

  6. leetcode Invert Binary Tree python

    # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = ...

  7. lc面试准备:Invert Binary Tree

    1 题目 Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 接口: public TreeNod ...

  8. <LeetCode OJ> 226. Invert Binary Tree

    226. Invert Binary Tree Total Accepted: 57653 Total Submissions: 136144 Difficulty: Easy Invert a bi ...

  9. Python解Leetcode: 226. Invert Binary Tree

    leetcode 226. Invert Binary Tree 倒置二叉树 思路:分别倒置左边和右边的结点,然后把根结点的左右指针分别指向右左倒置后返回的根结点. # Definition for ...

随机推荐

  1. Android自定义PopupWindow显示在控件上方或者下方

    记录学习之用 View view = mInflater.inflate(R.layout.layout_popupwindow, null); PopUpwindowLayout popUpwind ...

  2. SpringMVC 部署项目静态资源文件访问问题

    问题:采用SpringMVC 部署项目后程序加载或用浏览器访问时出现类似的警告,2011-01-19 10:52:51,646 WARN [org.springframework.web.servle ...

  3. cygwin-安装断点续传

    本文转载http://blog.chinaunix.net/uid-20178959-id-1731456.html 本文主要介绍正常下载安装(http://www.cnblogs.com/hwagg ...

  4. 10 函数的复写-override

    1.函数的复写:override 2.使用super调用父类的成员函数 class Person { String name; int age; void introduce() { System.o ...

  5. Win7下完全卸载Oracle 11g的步骤

    1 右击“计算机”-->管理-->服务和应用程序-->服务,停掉所有Oracle相关的服务(以Oracle打头的,比如OracleDBConsoleorcl). 2 开始--> ...

  6. HDU 5907 Find Q(简单字符串)

    传送门 Description Byteasar is addicted to the English letter 'q'. Now he comes across a string S consi ...

  7. jquery获取复选框的值

    勾选checkbox,并把勾选的值显示在某个div中 <!DOCTYPE html > <html> <head> <meta charset="U ...

  8. 屠蛟之路_你的名字_FirstDay

    君の名は. "号外,号外!屠龙天团众志成城,惊天技杀alpha龙!号外,号外--" 苦战十日,屠龙少年们依仗最后的惊天技终于将邪恶的alpha怪龙斩杀.但是对屠龙少年而言,这是一场 ...

  9. CentOS terminal 安装 matlab(mode=silent)

    1. 下载matlab for Unix 2014 ,需要crack文件 2. 挂载iso文件, mount -o loop,ro Mathworks.Matlab.R2014a.iso /media ...

  10. Mysql 列转行统计查询 、行转列统计查询

      -- ---------------------------- -- Table structure for `TabName` -- ---------------------------- D ...