摘要: bool helper(TreeNode *pA, TreeNode *pB) { if (!pA && !pB) return true; if (!pA || !pB) return false; // only one has node in a tree and... 阅读全文
posted @ 2014-09-04 22:06 山是水的故事 阅读(226) 评论(0) 推荐(0) 编辑
摘要: Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))... 阅读全文
posted @ 2014-09-04 21:27 山是水的故事 阅读(254) 评论(0) 推荐(0) 编辑
摘要: Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni... 阅读全文
posted @ 2014-09-04 17:45 山是水的故事 阅读(319) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
posted @ 2014-09-04 15:15 山是水的故事 阅读(618) 评论(0) 推荐(0) 编辑
摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw... 阅读全文
posted @ 2014-09-04 14:14 山是水的故事 阅读(456) 评论(0) 推荐(0) 编辑