摘要: 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 ~每天进步一点点~ 阅读(160) 评论(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 ~每天进步一点点~ 阅读(104) 评论(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 ~每天进步一点点~ 阅读(177) 评论(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 ~每天进步一点点~ 阅读(94) 评论(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 ~每天进步一点点~ 阅读(139) 评论(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 ~每天进步一点点~ 阅读(209) 评论(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 ~每天进步一点点~ 阅读(114) 评论(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 ~每天进步一点点~ 阅读(180) 评论(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 ~每天进步一点点~ 阅读(119) 评论(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 ~每天进步一点点~ 阅读(154) 评论(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 ~每天进步一点点~ 阅读(283) 评论(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 ~每天进步一点点~ 阅读(118) 评论(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 ~每天进步一点点~ 阅读(107) 评论(0) 推荐(0) 编辑