摘要:
Problem Description:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre... 阅读全文
posted @ 2014-06-29 19:39
HaruHaru
阅读(181)
评论(0)
推荐(0)
摘要:
Problem Description:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node do... 阅读全文
posted @ 2014-06-29 15:46
HaruHaru
阅读(117)
评论(0)
推荐(0)
摘要:
Problem Description:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Popul... 阅读全文
posted @ 2014-06-29 15:08
HaruHaru
阅读(111)
评论(0)
推荐(0)
摘要:
Problem Description:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your pr... 阅读全文
posted @ 2014-06-29 15:05
HaruHaru
阅读(117)
评论(0)
推荐(0)
摘要:
Problem Description:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1... 阅读全文
posted @ 2014-06-29 15:04
HaruHaru
阅读(138)
评论(0)
推荐(0)
摘要:
Problem Description:Given 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 @ 2014-06-29 15:03
HaruHaru
阅读(92)
评论(0)
推荐(0)
摘要:
Problem Description:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For ex... 阅读全文
posted @ 2014-06-29 15:02
HaruHaru
阅读(196)
评论(0)
推荐(0)
摘要:
Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most... 阅读全文
posted @ 2014-06-29 15:01
HaruHaru
阅读(101)
评论(0)
推荐(0)
摘要:
Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit... 阅读全文
posted @ 2014-06-29 15:00
HaruHaru
阅读(125)
评论(0)
推荐(0)
摘要:
Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit... 阅读全文
posted @ 2014-06-29 14:58
HaruHaru
阅读(141)
评论(0)
推荐(0)
摘要:
Problem Description:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below bina... 阅读全文
posted @ 2014-06-29 14:56
HaruHaru
阅读(131)
评论(0)
推荐(0)
摘要:
Problem Description:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a... 阅读全文
posted @ 2014-06-29 14:55
HaruHaru
阅读(126)
评论(0)
推荐(0)
摘要:
Problem Description:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Onl... 阅读全文
posted @ 2014-06-29 14:54
HaruHaru
阅读(189)
评论(0)
推荐(0)
摘要:
Problem Description:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one l... 阅读全文
posted @ 2014-06-29 14:52
HaruHaru
阅读(168)
评论(0)
推荐(0)
摘要:
Problem Description:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1... 阅读全文
posted @ 2014-06-29 14:51
HaruHaru
阅读(117)
评论(0)
推荐(0)
摘要:
Problem Description:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf ... 阅读全文
posted @ 2014-06-29 14:49
HaruHaru
阅读(143)
评论(0)
推荐(0)
摘要:
Problem Description:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in th... 阅读全文
posted @ 2014-06-29 14:48
HaruHaru
阅读(122)
评论(0)
推荐(0)
摘要:
Problem Description:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ... 阅读全文
posted @ 2014-06-29 14:46
HaruHaru
阅读(163)
评论(0)
推荐(0)
摘要:
Problem Description:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindr... 阅读全文
posted @ 2014-06-29 14:45
HaruHaru
阅读(114)
评论(0)
推荐(0)
摘要:
Problem Description:Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.Solution: 1 public UndirectedGraph... 阅读全文
posted @ 2014-06-29 14:43
HaruHaru
阅读(125)
评论(0)
推荐(0)
摘要:
Problem Description:There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas ta... 阅读全文
posted @ 2014-06-29 14:42
HaruHaru
阅读(167)
评论(0)
推荐(0)
摘要:
Problem Description:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to... 阅读全文
posted @ 2014-06-29 14:41
HaruHaru
阅读(132)
评论(0)
推荐(0)
摘要:
Problem Description:Given an array of integers, every element appearstwiceexcept for one. Find that single one.Solution: 1 public int singleNumber(int... 阅读全文
posted @ 2014-06-29 14:40
HaruHaru
阅读(129)
评论(0)
推荐(0)
摘要:
Problem Description:Given an array of integers, every element appearsthreetimes except for one. Find that single one.Solution:1 Arrays.sort(A... 阅读全文
posted @ 2014-06-29 14:38
HaruHaru
阅读(95)
评论(0)
推荐(0)
摘要:
Problem Description:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null... 阅读全文
posted @ 2014-06-29 14:36
HaruHaru
阅读(134)
评论(0)
推荐(0)
摘要:
Problem Description:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more diction... 阅读全文
posted @ 2014-06-29 14:03
HaruHaru
阅读(188)
评论(0)
推荐(0)
摘要:
Problem Description:Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Ret... 阅读全文
posted @ 2014-06-29 14:01
HaruHaru
阅读(184)
评论(0)
推荐(0)
摘要:
Problem Description:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Solution: 1 public bo... 阅读全文
posted @ 2014-06-29 14:00
HaruHaru
阅读(121)
评论(0)
推荐(0)
摘要:
Problem Description:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without u... 阅读全文
posted @ 2014-06-29 13:58
HaruHaru
阅读(161)
评论(0)
推荐(0)
摘要:
Problem Description:Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the no... 阅读全文
posted @ 2014-06-29 13:57
HaruHaru
阅读(162)
评论(0)
推荐(0)
摘要:
Problem Description:Given a binary tree, return thepreordertraversal of its nodes' values.Solution: 1 public List preorderTraversal(TreeNode root)... 阅读全文
posted @ 2014-06-29 13:56
HaruHaru
阅读(116)
评论(0)
推荐(0)
摘要:
Problem Description:Given a binary tree, return thepostordertraversal of its nodes' valuesSolution: 1 public List postorderTraversal(TreeNode root) { ... 阅读全文
posted @ 2014-06-29 13:54
HaruHaru
阅读(147)
评论(0)
推荐(0)
摘要:
Problem Description:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.ge... 阅读全文
posted @ 2014-06-29 13:53
HaruHaru
阅读(148)
评论(0)
推荐(0)
摘要:
Problem Description:Sort a linked list using insertion sort.Solution: 1 public class Solution { 2 public ListNode insertionSortList(ListNode head)... 阅读全文
posted @ 2014-06-29 13:51
HaruHaru
阅读(140)
评论(0)
推荐(0)
摘要:
Problem Description:Sort a linked list inO(nlogn) time using constant space complexity.Solution: 1 public ListNode sortList(ListNode head) { 2 ... 阅读全文
posted @ 2014-06-29 13:49
HaruHaru
阅读(177)
评论(0)
推荐(0)
摘要:
Problem Description:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.Solution: 1 public int maxPoint... 阅读全文
posted @ 2014-06-29 13:47
HaruHaru
阅读(134)
评论(0)
推荐(0)
摘要:
Problem Description:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integ... 阅读全文
posted @ 2014-06-29 13:40
HaruHaru
阅读(175)
评论(0)
推荐(0)
摘要:
Problem Description:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Solution: ... 阅读全文
posted @ 2014-06-29 13:36
HaruHaru
阅读(116)
评论(0)
推荐(0)
摘要:
Problem Description:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Solution: 递归。 1 public List>... 阅读全文
posted @ 2014-06-29 13:31
HaruHaru
阅读(117)
评论(0)
推荐(0)

浙公网安备 33010602011771号