Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".解题思路:这题比较基础,但想写对也不太容易。首先知道的一点,不能将数字直接Integer.pa...
分类:
其他好文 时间:
2015-02-24 21:02:42
阅读次数:
158
https://oj.leetcode.com/problems/balanced-binary-tree/Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced bina...
分类:
其他好文 时间:
2015-02-24 17:31:15
阅读次数:
118
https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/Given a binary tree, find its minimum depth.The minimum depth is the number of nodes alo...
分类:
其他好文 时间:
2015-02-24 16:20:19
阅读次数:
141
Given a binary tree, return the postorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},
return [3,2,1].Note: Recursive solution is trivial, could you do it iteratively?...
分类:
其他好文 时间:
2015-02-24 07:02:03
阅读次数:
180
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n...
分类:
其他好文 时间:
2015-02-24 06:55:58
阅读次数:
171
Given a binary tree, return the preorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},
return [3,2,1].Note: Recursive solution is trivial, could you do it iteratively?递归...
分类:
其他好文 时间:
2015-02-24 01:53:20
阅读次数:
192
二分搜索,和LeetCode 153. Find Minimum in Rotated Sorted Array相似。
只是在num[begin] == num[mid]时,需要binary_search(++ begin, end, num); 这时仅将begin移进一位,并没有进行二分查找。
所以如测试用例为 num = {1, 1, 1, 1, 1, ..., 1}等特殊情况时,最坏情况...
分类:
其他好文 时间:
2015-02-24 00:50:43
阅读次数:
206
二分查找。
因为在旋转前的数组是排好序了的,
所以当num[begin] > num[mid]时,表示我们要搜寻的最小数字在num[begin, ..., mid]之间;
反之,num[begin]
例:考虑num = {5, 6, 7, 1, 2, 3, 4},
begin = 0, end = 6, mid = 3
num[begin] = 5 > num[m...
分类:
其他好文 时间:
2015-02-23 23:43:09
阅读次数:
350
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 ...
分类:
其他好文 时间:
2015-02-23 15:26:34
阅读次数:
168
odt文件其实由若干文本文件组成,git 经过一些配置是可以支持diff的。
step 1:
在git项目中i添加.gitattributes文件, 内容如下:
*.odt diff=odt
step 2:
在.git/config文件中添加下面一段:
[diff "odt"]
binary = true
textconv = /usr/local/bin/odt-to-txt...
分类:
其他好文 时间:
2015-02-23 14:18:21
阅读次数:
144