问题描述:
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
代码:
public class AddBinary { //java
public String addBinary(St...
分类:
其他好文 时间:
2014-10-28 20:06:26
阅读次数:
183
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
实现二进制数相加,算法很简单就是两个String每位去相加,然后判断是否要进位。
一开始想到了一个不同的算法,即将两个String转为int型然后相加...
分类:
其他好文 时间:
2014-10-28 13:59:50
阅读次数:
237
问题描述:
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next r...
分类:
其他好文 时间:
2014-10-28 10:23:24
阅读次数:
148
1,关于递归还是要有时间就练习,又有些生疏了/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeN...
分类:
其他好文 时间:
2014-10-28 07:02:47
阅读次数:
141
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...
分类:
其他好文 时间:
2014-10-28 07:02:27
阅读次数:
171
问题描述:
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of
every node nev...
分类:
其他好文 时间:
2014-10-27 21:25:12
阅读次数:
193
问题描述:
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 example:
Given binary tree {3,9,20,#,#,...
分类:
其他好文 时间:
2014-10-27 21:21:00
阅读次数:
190
问题描述:
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 ...
分类:
其他好文 时间:
2014-10-27 21:19:41
阅读次数:
231
问题描述:
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ 9 ...
分类:
其他好文 时间:
2014-10-27 21:19:34
阅读次数:
236
问题描述:
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 and the nodes have the same value.
...
分类:
其他好文 时间:
2014-10-27 21:17:54
阅读次数:
165