摘要: Path SumGiven 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 give... 阅读全文
posted @ 2015-09-16 23:28 Sean_le 阅读(146) 评论(0) 推荐(0) 编辑
摘要: House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint... 阅读全文
posted @ 2015-09-16 23:06 Sean_le 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callin... 阅读全文
posted @ 2015-09-16 21:54 Sean_le 阅读(118) 评论(0) 推荐(0) 编辑
摘要: Pascal's Triangle IIGiven an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your alg... 阅读全文
posted @ 2015-09-16 20:29 Sean_le 阅读(95) 评论(0) 推荐(0) 编辑
摘要: Pascal's TriangleGivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,... 阅读全文
posted @ 2015-09-16 20:25 Sean_le 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Implement Stack using QueuesImplement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the eleme... 阅读全文
posted @ 2015-09-16 18:12 Sean_le 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-l... 阅读全文
posted @ 2015-09-16 17:11 Sean_le 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums... 阅读全文
posted @ 2015-09-16 16:24 Sean_le 阅读(106) 评论(0) 推荐(0) 编辑
摘要: First Bad VersionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fa... 阅读全文
posted @ 2015-09-16 16:10 Sean_le 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Perfect SquaresGiven a positive integern, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum ton.For example, gi... 阅读全文
posted @ 2015-09-16 15:45 Sean_le 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Kth Smallest Element in a BSTGiven a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is alw... 阅读全文
posted @ 2015-09-16 11:17 Sean_le 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt... 阅读全文
posted @ 2015-09-16 10:48 Sean_le 阅读(92) 评论(0) 推荐(0) 编辑
摘要: CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3... 阅读全文
posted @ 2015-09-16 10:33 Sean_le 阅读(141) 评论(0) 推荐(0) 编辑