随笔分类 -  leetcode

摘要:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文
posted @ 2014-05-17 14:01 一弦一仙 阅读(160) 评论(0) 推荐(0)
摘要: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 fol... 阅读全文
posted @ 2014-05-17 13:56 一弦一仙 阅读(163) 评论(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-05-17 13:54 一弦一仙 阅读(187) 评论(0) 推荐(0)
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2014-05-16 15:54 一弦一仙 阅读(163) 评论(0) 推荐(0)
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2014-05-16 14:40 一弦一仙 阅读(150) 评论(0) 推荐(0)
摘要:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: For example, Given:start 阅读全文
posted @ 2014-05-15 22:22 一弦一仙 阅读(256) 评论(0) 推荐(0)
摘要:Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: For example, Give 阅读全文
posted @ 2014-05-14 20:21 一弦一仙 阅读(148) 评论(0) 推荐(0)
摘要:Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].public class S... 阅读全文
posted @ 2014-05-13 16:45 一弦一仙 阅读(179) 评论(0) 推荐(0)
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
posted @ 2014-05-13 14:34 一弦一仙 阅读(121) 评论(0) 推荐(0)
摘要:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文
posted @ 2014-05-13 11:24 一弦一仙 阅读(132) 评论(0) 推荐(0)
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =... 阅读全文
posted @ 2014-05-12 23:33 一弦一仙 阅读(126) 评论(0) 推荐(0)
摘要:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.public class S... 阅读全文
posted @ 2014-05-12 00:26 一弦一仙 阅读(148) 评论(0) 推荐(0)
摘要:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.public class So... 阅读全文
posted @ 2014-05-12 00:06 一弦一仙 阅读(161) 评论(0) 推荐(0)
摘要:Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2014-05-11 23:27 一弦一仙 阅读(199) 评论(0) 推荐(0)
摘要:Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri... 阅读全文
posted @ 2014-05-11 20:34 一弦一仙 阅读(154) 评论(0) 推荐(0)
摘要:Spiral MatrixGiven a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[... 阅读全文
posted @ 2014-05-11 20:23 一弦一仙 阅读(145) 评论(0) 推荐(0)
摘要:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:先将矩阵转置,然后将第一列与最后... 阅读全文
posted @ 2014-05-11 18:57 一弦一仙 阅读(136) 评论(0) 推荐(0)
摘要:Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],... 阅读全文
posted @ 2014-05-11 17:10 一弦一仙 阅读(162) 评论(0) 推荐(0)
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文
posted @ 2014-05-11 16:04 一弦一仙 阅读(130) 评论(0) 推荐(0)
摘要:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2014-05-11 15:50 一弦一仙 阅读(135) 评论(0) 推荐(0)