关于镜像树的相关操作,利用递归可以很简单的解决问题。 注意判断根节点是不是null/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNod...
分类:
其他好文 时间:
2015-04-25 22:28:50
阅读次数:
180
problem:
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ 2 2
/ \ / 3 4 4 ...
分类:
其他好文 时间:
2015-04-20 11:16:24
阅读次数:
209
题目链接:Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ \
2 2
/ \ / \
3 ...
分类:
其他好文 时间:
2015-04-16 09:06:02
阅读次数:
147
在上一篇介绍了linux驱动的调试方法,这一篇介绍一下在驱动编程中会遇到的并发和竟态以及如何处理并发和竞争。
首先什么是并发与竟态呢?并发(concurrency)指的是多个执行单元同时、并行被执行。而并发的执行单元对共享资源(硬件资源和软件上的全局、静态变量)的访问则容易导致竞态(race conditions)。可能导致并发和竟态的情况有:
SMP(Symmetric Multi-Pr...
分类:
系统相关 时间:
2015-04-11 14:55:06
阅读次数:
257
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3...
分类:
其他好文 时间:
2015-04-09 21:57:21
阅读次数:
131
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solutio...
分类:
其他好文 时间:
2015-04-05 09:04:00
阅读次数:
134
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ 2 2
/ \ / 3 4 4 3
But the f...
分类:
其他好文 时间:
2015-04-04 23:50:46
阅读次数:
338
问题:判断二叉树是否为镜像二叉树分析:递归判断,根节点单独判断,然后递归左结点和右结点,之后每次一起递归左结点的左结点和右结点的右结点比较,左结点的右结点和右结点的左结点比较。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { .....
分类:
其他好文 时间:
2015-04-03 00:11:45
阅读次数:
198
链接:https://leetcode.com/problems/symmetric-tree/
此题就是判断一棵二叉树是否为对称二叉树,刚开始以为中序遍历输出,然后看是否是为回文字串,但是这种思路是错了,如[1,2,3,#,3,#,2].
代码如下:
通过循环递归判断左孩子的左子树与右孩子的右子树 及 左孩子的右子树与右孩子的左子树即可得到结果。
class Solution {
pub...
分类:
其他好文 时间:
2015-04-02 18:52:21
阅读次数:
143
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ...
分类:
其他好文 时间:
2015-03-29 00:30:42
阅读次数:
154