摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
Pascal's TriangleGivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,... 阅读全文
摘要:
Implement Stack using QueuesImplement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the eleme... 阅读全文
摘要:
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... 阅读全文
摘要:
Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt... 阅读全文
摘要:
CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3... 阅读全文