随笔分类 -  leedcode

上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文
posted @ 2015-07-14 17:25 ~每天进步一点点~ 阅读(152) 评论(0) 推荐(0)
摘要:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.public class Solution { public void setZeroes(int[][] matr... 阅读全文
posted @ 2015-07-14 17:10 ~每天进步一点点~ 阅读(143) 评论(0) 推荐(0)
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"public class Solution { ... 阅读全文
posted @ 2015-07-13 23:02 ~每天进步一点点~ 阅读(168) 评论(0) 推荐(0)
摘要:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2015-07-13 22:22 ~每天进步一点点~ 阅读(112) 评论(0) 推荐(0)
摘要:Implementint sqrt(int x).Compute and return the square root ofx.public class Solution { //本题利用了牛顿迭代法:设r是f(x) = 0的根(x^2-k=f(x)),选取x0作为r初始近似值,过点(x0,f... 阅读全文
posted @ 2015-07-13 22:08 ~每天进步一点点~ 阅读(186) 评论(0) 推荐(0)
摘要:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".public class Solution { public String addBin... 阅读全文
posted @ 2015-07-13 21:34 ~每天进步一点点~ 阅读(99) 评论(0) 推荐(0)
摘要:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at... 阅读全文
posted @ 2015-07-13 18:10 ~每天进步一点点~ 阅读(146) 评论(0) 推荐(0)
摘要:Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem stat... 阅读全文
posted @ 2015-07-13 17:56 ~每天进步一点点~ 阅读(213) 评论(0) 推荐(0)
摘要:Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:Yo... 阅读全文
posted @ 2015-07-13 16:19 ~每天进步一点点~ 阅读(121) 评论(0) 推荐(0)
摘要:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文
posted @ 2015-07-13 15:43 ~每天进步一点点~ 阅读(191) 评论(0) 推荐(0)
摘要:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-07-13 14:35 ~每天进步一点点~ 阅读(128) 评论(0) 推荐(0)
摘要:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL./** *... 阅读全文
posted @ 2015-07-13 14:21 ~每天进步一点点~ 阅读(161) 评论(0) 推荐(0)
摘要:The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie... 阅读全文
posted @ 2015-07-13 12:39 ~每天进步一点点~ 阅读(294) 评论(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 @ 2015-07-13 10:52 ~每天进步一点点~ 阅读(128) 评论(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 @ 2015-07-13 10:43 ~每天进步一点点~ 阅读(115) 评论(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]./** * Definiti... 阅读全文
posted @ 2015-07-12 23:47 ~每天进步一点点~ 阅读(111) 评论(0) 推荐(0)
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2015-07-12 23:19 ~每天进步一点点~ 阅读(89) 评论(0) 推荐(0)
摘要:Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],... 阅读全文
posted @ 2015-07-12 21:48 ~每天进步一点点~ 阅读(168) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文
posted @ 2015-07-12 21:25 ~每天进步一点点~ 阅读(161) 评论(0) 推荐(0)
摘要:首先对要求的数进行质因数分解,然后求各因数的幂的积数,比如600=2^3*3^1*5^2那么因子个数是(3+1)*(1+1)*(2+1)=24public class TestYuman{ public static void main(String[] args){ i... 阅读全文
posted @ 2015-07-12 20:52 ~每天进步一点点~ 阅读(1253) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页