问题:给一个二叉树,写一个算法判断这个树是不是balanced。Solution
#1.第一次遇到这个问题时我的解法,如下:public class Solution { public boolean isBalanced(TreeNode
root) { if(root == ...
分类:
其他好文 时间:
2014-05-05 12:50:49
阅读次数:
263
Given an array of non-negative integers, you
are initially positioned at the first index of the array.Each element in the
array represents your maximu...
分类:
其他好文 时间:
2014-05-05 10:05:58
阅读次数:
300
题目:Given an array of strings, return all groups of
strings that are anagrams.Note: All inputs will be in lower-case.class Solution
{public: vector ...
分类:
其他好文 时间:
2014-05-04 20:48:08
阅读次数:
608
Given a non-negative number represented as an array
of digits, plus one to the number.The digits are stored such that the most
significant digit is at...
分类:
其他好文 时间:
2014-05-04 19:46:18
阅读次数:
372
题目
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
Valid operators are +, -, *, /.
Each operand may be an integer or another expression.
Some examples:
["2...
分类:
其他好文 时间:
2014-05-04 18:34:44
阅读次数:
272
明知道明早要考试,可还是忍不住打开电脑想水一题。不过还是在这题上WA了好几次....看见自己有多渣!有个道理发现了很久,直到今天才意识到它的严重性,反复的做题只能让你不断的巩固已有的知识,而对于新知识的探索是少只又少,所以必须要通过多读书来获取新的知识,这样才能够扩充知识面。而之前的我就是忽略了读书...
分类:
其他好文 时间:
2014-05-04 12:18:21
阅读次数:
218
leetcode中有这么一道题,非递归来实现二叉树的遍历。二叉树的后序遍历顺序为,root->left,
root->right,
root,因此需要保存根节点的状态。显然使用栈来模拟递归的过程,但是难点是怎么从root->right转换到root。方法1:对于节点p可以分情况讨论1.
p如果是叶子...
分类:
其他好文 时间:
2014-05-04 10:39:13
阅读次数:
251
题目:
Given a string S and a string T, count the number of distinct subsequences of T in S.
A subsequence of a string is a new string which is formed from the original string by deleting some (c...
分类:
其他好文 时间:
2014-05-03 21:48:19
阅读次数:
252
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an...
分类:
其他好文 时间:
2014-05-03 21:35:49
阅读次数:
310
EXOCENTER OF A TRIANGLE
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 3209
Accepted: 1259
Description
Given a triangle ABC, the Extriangles of ABC are cons...
分类:
其他好文 时间:
2014-05-03 21:14:28
阅读次数:
340