1 class Solution { 2 public: 3 int minDepth(TreeNode *root) { 4 if (root == nullptr) return 0; 5 if (root->left != nullptr&&root-...
分类:
其他好文 时间:
2014-10-29 12:08:21
阅读次数:
153
recursive 1 #include 2 #include 3 using namespace std; 4 5 struct TreeNode { 6 int val; 7 TreeNode *left; 8 TreeNode *right; 9 ...
分类:
其他好文 时间:
2014-10-29 10:20:20
阅读次数:
199
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100". 1 public class Solution { 2 public String ...
分类:
其他好文 时间:
2014-10-29 00:11:02
阅读次数:
245
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".思路简单(同Add Two Numbers),可从代码得知,需要注意字符在字符串中的插入;co...
分类:
其他好文 时间:
2014-10-28 23:59:02
阅读次数:
343
问题描述:
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