https://leetcode.com/problems/path-sum/Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values...
分类:
其他好文 时间:
2015-05-05 01:15:10
阅读次数:
184
题目Given two binary trees, write a function to check if they are equal or not.
分析写一个检查两个二叉树是否相等的函数...
分类:
其他好文 时间:
2015-05-04 22:16:06
阅读次数:
114
Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For examp...
分类:
其他好文 时间:
2015-05-04 20:14:35
阅读次数:
182
Add Binary
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
解题思路:
题意为两个字符串表示的二进制相加,求结果。记住常字符串与字符串变量能够相加,但是字符串不能与数字相加,字符...
分类:
其他好文 时间:
2015-05-04 20:12:43
阅读次数:
149
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110...
分类:
其他好文 时间:
2015-05-04 18:18:59
阅读次数:
71
题目描述:
Add Binary
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
解题思路:
求两个二进制组成的数字的和。首先有几种特殊的情况,a、b均为空,a为空、b非空,a非空、b为空;我们...
分类:
其他好文 时间:
2015-05-04 18:13:48
阅读次数:
154
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n)
space is pretty straight forward. Could you devis...
分类:
其他好文 时间:
2015-05-04 18:06:38
阅读次数:
119
Path Sum
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.
For example:
Given the below bina...
分类:
其他好文 时间:
2015-05-04 15:30:49
阅读次数:
113
找binary tree中两个node第一个公共祖先。注意不一定是BST想法:p,q都在左子树,就branch left。如果都在right,就branch right。如果不在same side,就返回first common ancestor所以主要是在left subtree和right su...
分类:
其他好文 时间:
2015-05-04 13:31:09
阅读次数:
155
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next...
分类:
其他好文 时间:
2015-05-04 13:27:57
阅读次数:
115