摘要: 需要注意overflow,特别是Integer.MIN_VALUE这个数字。 需要掌握二分法。 不用除法的除法,分而治之的乘方 2. Add Two Numbers You are given two linked lists representing two non-negative number 阅读全文
posted @ 2016-12-28 11:13 Gryffin 阅读(701) 评论(0) 推荐(0) 编辑
摘要: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following unique pe 阅读全文
posted @ 2016-12-28 10:34 Gryffin 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 这道题目一直不会做,因为要考虑的corner case 太多。 1. divisor equals 0. 2. dividend equals 0. 3. Is the result negative? 4. when dividend equals Integer.MIN_VALUE and di 阅读全文
posted @ 2016-12-27 12:24 Gryffin 阅读(234) 评论(0) 推荐(0) 编辑
摘要: StringBuilder.charAt(int index); StringBuilder.deleteCharAt(int index); StringBuilder.setCharAt(int index); String.indexOf(String str, int fromIndex); 阅读全文
posted @ 2016-12-27 11:18 Gryffin 阅读(119) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int threeSumClosest(int[] nums, int target) { Arrays.sort(nums); int length = nums.length; int rr = Integer.MAX_VALUE; int result = ... 阅读全文
posted @ 2016-12-27 11:04 Gryffin 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 如果某一个字母代表的数字大于上一个字母代表的数字小,那么加上这个数字,否则,减去两倍的前一个数字,然后加上这一位数字。 阅读全文
posted @ 2016-12-27 10:28 Gryffin 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 关于罗马数字: I: 1V: 5X: 10L: 50C: 100D: 500M: 1000字母可以重复,但不超过三次,当需要超过三次时,用与下一位的组合表示:I: 1, II: 2, III: 3, IV: 4C: 100, CC: 200, CCC: 300, CD: 400 提取每一位digit 阅读全文
posted @ 2016-12-27 08:46 Gryffin 阅读(143) 评论(0) 推荐(0) 编辑
摘要: I found summary of k Sum problem and solutions in leetcode on the Internet. http://www.sigmainfy.com/blog/summary-of-ksum-problems.html 阅读全文
posted @ 2016-09-06 06:07 Gryffin 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Practice 16~27一异常控制流(exceptional control flow)机制: 1 try{ 2 3 } 4 catch( e){ 5 6 throw e; //若不能处理该异常,则抛出 7 } 8 finally{ 9 10 }若在try... 阅读全文
posted @ 2016-01-09 20:16 Gryffin 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Practice 2,3final作用于by value变量时,一旦赋值不可更改作用于by reference变量时,一旦不能指向第二个对象,但是可以改变对象的内容。比如不可以第二次=new xx();作用于函数时,该函数不能被subclass覆写作用于class时,改class内所有函数必须是fi... 阅读全文
posted @ 2016-01-09 19:14 Gryffin 阅读(112) 评论(0) 推荐(0) 编辑