2013年10月2日

Merge Two Sorted Lists

摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 1 /** 2 ... 阅读全文

posted @ 2013-10-02 14:40 Step-BY-Step 阅读(160) 评论(0) 推荐(0) 编辑

Add Binary

摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100". 1 public class Solution { 2 public String addBinary(String a, String b) { 3 // Start typing your Java solution below 4 // DO NOT write main() function 5 StringBuffer 阅读全文

posted @ 2013-10-02 07:53 Step-BY-Step 阅读(176) 评论(0) 推荐(0) 编辑

Valid Number

摘要: 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 @ 2013-10-02 07:19 Step-BY-Step 阅读(281) 评论(0) 推荐(0) 编辑

Plus One

摘要: Given a number represented as an array of digits, plus one to the number. 1 public class Solution { 2 public int[] plusOne(int[] digits) { 3 // Start typing your Java solution below 4 // DO NOT write main() function 5 int carry = 0; 6 boolean sig = false; 7 ... 阅读全文

posted @ 2013-10-02 07:13 Step-BY-Step 阅读(203) 评论(0) 推荐(0) 编辑

Text Justification

摘要: Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces' 'when necessary so that each line 阅读全文

posted @ 2013-10-02 05:22 Step-BY-Step 阅读(214) 评论(0) 推荐(0) 编辑

Sqrt(x)

摘要: Implementint sqrt(int x).Compute and return the square root ofx.牛顿迭代法: 1 public class Solution { 2 double eps = 0.000001; 3 public int sqrt(in... 阅读全文

posted @ 2013-10-02 05:09 Step-BY-Step 阅读(649) 评论(0) 推荐(0) 编辑

Corner case

摘要: Acorner case(orpathological case) is a problem or situation that occurs only outside of normal operatingparameters—specifically one that manifests itself when multiple environmental variables or conditions are simultaneously at extreme levels, even though each parameter is within the specified range 阅读全文

posted @ 2013-10-02 04:22 Step-BY-Step 阅读(570) 评论(0) 推荐(0) 编辑

Simplify Path

摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cas... 阅读全文

posted @ 2013-10-02 04:18 Step-BY-Step 阅读(347) 评论(0) 推荐(0) 编辑

导航