摘要: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文
posted @ 2015-04-19 16:12 amazingzoe 阅读(148) 评论(0) 推荐(0)
摘要: Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.New version: 4ms 1 class S... 阅读全文
posted @ 2015-04-19 15:36 amazingzoe 阅读(119) 评论(0) 推荐(0)
摘要: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Analyse: Be cautious abou the expression of ... 阅读全文
posted @ 2015-04-18 19:26 amazingzoe 阅读(116) 评论(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-04-18 16:10 amazingzoe 阅读(155) 评论(0) 推荐(0)
摘要: Implement pow(x,n).Analyse: To avoid exceeding time, first consider the basic situation, see line5~11; then set some precision s.t. when the differenc... 阅读全文
posted @ 2015-04-18 11:26 amazingzoe 阅读(115) 评论(0) 推荐(0)
摘要: Implementint sqrt(int x).Compute and return the square root ofx.好的解法: 二分法,注意边界条件。当不满足循环条件时,low>high,经过验证,low-1为正确答案。时间:16ms 1 class Solution { 2 publi... 阅读全文
posted @ 2015-04-18 10:25 amazingzoe 阅读(163) 评论(0) 推荐(0)
摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".Analyse: Using XOR(^) to compute the result of ... 阅读全文
posted @ 2015-04-18 10:15 amazingzoe 阅读(129) 评论(0) 推荐(0)
摘要: 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.***Note**... 阅读全文
posted @ 2015-04-17 16:58 amazingzoe 阅读(156) 评论(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-04-17 13:45 amazingzoe 阅读(115) 评论(0) 推荐(0)
摘要: Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(... 阅读全文
posted @ 2015-04-13 13:48 amazingzoe 阅读(125) 评论(0) 推荐(0)