上一页 1 2 3 4 5 6 7 ··· 14 下一页
摘要: 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 example, given the following triangle[ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bottom is11(i.e.,2+3+5+1= 11).Note:Bonus point if you... 阅读全文
posted @ 2013-03-01 07:23 西施豆腐渣 阅读(248) 评论(0) 推荐(0) 编辑
摘要: Trapping Rain WaterMar 10 '12Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example,Given[0,1,0,2,1,0,1,3,2,1,2,1], return6.The above elevation map is represented by array [0,1,0,2,1,0,1,3,2, 阅读全文
posted @ 2013-03-01 06:20 西施豆腐渣 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be only one unique solution.A sudoku puzzle......and its solution numbers marked in red.uncompleted.public class Solution { ArrayList<HashSet< 阅读全文
posted @ 2013-03-01 00:59 西施豆腐渣 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Search a 2D MatrixApr 7 '12Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.For example,Consider th 阅读全文
posted @ 2013-02-26 09:03 西施豆腐渣 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Path SumOct 14 '12Given 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 given sum.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11... 阅读全文
posted @ 2013-02-26 05:59 西施豆腐渣 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).The replacement must be in-place, do not allocat 阅读全文
posted @ 2013-02-23 17:52 西施豆腐渣 阅读(97) 评论(0) 推荐(0) 编辑
摘要: Word Ladder IIFeb 11Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) fromstart toend, such that:Only one letter can be changed at a timeEach intermediate word must exist in the dictionaryFor example,Given:start = "hit"end = "cog"dict 阅读全文
posted @ 2013-02-22 10:29 西施豆腐渣 阅读(516) 评论(0) 推荐(0) 编辑
摘要: Sum Root to Leaf Numbers2 daysGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find the total sum of all root-to-leaf numbers.For example, 1 / \ 2 3 The root-to-leaf p... 阅读全文
posted @ 2013-02-22 05:38 西施豆腐渣 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Longest Consecutive SequenceFeb 14Given 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 consecutive elements sequence is[1, 2, 3, 4]. Return its length:4.Your algorithm should run in O(n) complexity.publi 阅读全文
posted @ 2013-02-22 04:27 西施豆腐渣 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Word LadderFeb 11Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be changed at a timeEach intermediate word must exist in the dictionaryFor example,Given:start="hit"end="cog"dict=[& 阅读全文
posted @ 2013-02-21 07:44 西施豆腐渣 阅读(181) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 14 下一页