
算术
文章平均质量分 68
不刷脸皮要刷题
这个作者很懒,什么都没留下…
展开
-
Divide two integers
注意dividend是0的情况,这个时候sum总是比被除数大的!尼玛考虑负数的情况!而且还有溢出的情况。。。。 -(-2147483648)溢出啦 亲。。。要从O(n) -> O(lgn) -> O(1)转载 2014-10-09 12:07:58 · 255 阅读 · 0 评论 -
Palindrome Number溢出怎么处理?
1. x == reverse(x)?2. public class Solution { // 1. could negative number be Palindrome? // 2. reverse Integer! public boolean isPalindrome(int x) { if (x < 0) return false转载 2014-10-09 21:10:11 · 287 阅读 · 0 评论 -
Add two numbers & Add binary
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 digit. Add the two numbers and return it as a link转载 2014-10-09 11:58:34 · 294 阅读 · 0 评论 -
String to Integer(atoi)
1, 考虑溢出 -》用long。 If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned.2,转载 2014-10-19 21:08:03 · 366 阅读 · 0 评论 -
Multiply String
public class Solution { public String multiply(String num1, String num2) { if (num1 == null || num2 == null) { return null; } int len1 = num1.length(); int l转载 2014-10-19 20:57:37 · 313 阅读 · 0 评论