Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1 1 /** 2 * Definition for a binary tre...
分类:
其他好文 时间:
2015-07-20 10:35:00
阅读次数:
93
Write a function that takes an unsigned integer and returns the number of ’1' bits it hasFor example, the 32-bit integer ’11' has binary representatio...
分类:
其他好文 时间:
2015-07-20 10:29:37
阅读次数:
104
After loooong pause, adding next (well, second) post to the “series“. This time, I'd like to describe how logging works. And I don't mean binary loggi...
分类:
数据库 时间:
2015-07-20 09:05:20
阅读次数:
201
114 Flatten Binary Tree to Linked List这道题就是Preorder的稍微变种, 记住 pre 的节点就好class Solution: def __init__(self): self.pre = TreeNode("dummy") ...
分类:
其他好文 时间:
2015-07-20 08:01:33
阅读次数:
127
Title:有两个不同大小的二进制树:T1有上百万的节点;T2有好几百的节点。请设计一种算法,判定T2是否为T1的子树class Solution {public: /** * @param T1, T2: The roots of binary tree. * @return...
分类:
其他好文 时间:
2015-07-19 23:23:04
阅读次数:
222
This problem is generally believed to have two solutions: the top down approach and the bottom up way.
1.The first method checks whether the tree is balanced strictly according to the definition of b...
分类:
其他好文 时间:
2015-07-19 21:45:10
阅读次数:
108
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an...
分类:
其他好文 时间:
2015-07-19 21:37:22
阅读次数:
139
前言前两篇文章二叉树和二叉搜索树中已经涉及到了二叉树的三种遍历。递归写法,仅仅要理解思想,几行代码。但是非递归写法却非常不easy。这里特地总结下,透彻解析它们的非递归写法。当中。中序遍历的非递归写法最简单,后序遍历最难。我们的讨论基础是这种: //Binary Tree Nodetypedef s...
分类:
其他好文 时间:
2015-07-19 21:25:45
阅读次数:
167
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
分类:
其他好文 时间:
2015-07-19 20:03:00
阅读次数:
108
imshowDescriptionimshow(I) displays image I in a Handle Graphics® figure, where I is a grayscale, RGB (truecolor), or binary image. For binary image.....
分类:
其他好文 时间:
2015-07-19 19:30:32
阅读次数:
201