摘要: 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)