2016年7月5日

摘要: There are two ways for the problem:1. Tradition: Setup a map or set.2. Bit operation: x ^ x = 0; so if the number keep XOR, the same ones will cancel 阅读全文
posted @ 2016-07-05 08:49 codingEskimo 阅读(136) 评论(0) 推荐(0)
摘要: 这是一个bit opperation 的题目。 九章算法有一个比较好的解释 http://www.jiuzhang.com/solutions/a-b-problem/ a^b是不进位的加法,什么时候需要进位呢,就是a和b都是1的情况。这个时候a&b就能给出所有需要进位的位,所谓进位就是需要左移一位 阅读全文
posted @ 2016-07-05 08:14 codingEskimo 阅读(148) 评论(0) 推荐(0)

2015年12月10日

摘要: 首先看一下只需要return 长度的解法: public class Solution { public int lengthOfLongestSubstring(String s) { /*** * Basic idea: N(o^2): for each character, continue 阅读全文
posted @ 2015-12-10 13:06 codingEskimo 阅读(128) 评论(0) 推荐(0)

2015年12月9日

摘要: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solu 阅读全文
posted @ 2015-12-09 14:10 codingEskimo 阅读(162) 评论(0) 推荐(0)
摘要: public class Solution { public int[] twoSum(int[] nums, int target) { /* Basic idea: Load the array into a hashMap with the value of each array elemen 阅读全文
posted @ 2015-12-09 11:34 codingEskimo 阅读(109) 评论(0) 推荐(0)

2015年12月1日

摘要: public class Solution { /** * @param s: The first string * @param b: The second string * @return true or false */ public boolean... 阅读全文
posted @ 2015-12-01 13:54 codingEskimo 阅读(126) 评论(0) 推荐(0)
摘要: /** * Definition for ListNode. * public class ListNode { * int val; * ListNode next; * ListNode(int val) { * this.val = val; * this.next = null; * } * 阅读全文
posted @ 2015-12-01 09:54 codingEskimo 阅读(108) 评论(0) 推荐(0)
摘要: class Solution { /** * @return: The same instance of this class every time */ //http://www.cnblogs.com/EdwardLiu/p/4443230.html ... 阅读全文
posted @ 2015-12-01 09:35 codingEskimo 阅读(149) 评论(0) 推荐(0)

2015年11月13日

摘要: Count how many 1 in binary representation of a 32-bit integer. Example Given 32, return 1 Given 5, return 2 Given 1023, return 9 Count how many 1 in b 阅读全文
posted @ 2015-11-13 12:41 codingEskimo 阅读(135) 评论(0) 推荐(0)
摘要: public class Solution { /** * @param string: An array of Char * @param length: The true length of the string * @return: The true length... 阅读全文
posted @ 2015-11-13 11:24 codingEskimo 阅读(253) 评论(0) 推荐(0)

导航