2014年4月7日

摘要: Problem link:http://oj.leetcode.com/problems/single-number-ii/The problem seems like the Single Number. Suppose we have following (3m+1) numbers in the array A:x0, x1, x1, x1, ..., xm, xm, xmWe are asked to find out the value of x0.However we cannot solve it using XOR since all xi has odd number of 阅读全文

posted @ 2014-04-07 04:54 卢泽尔 阅读(178) 评论(0) 推荐(0)

摘要: Prolbem link:http://oj.leetcode.com/problems/single-number/This prolbem can be solved by using XOR(exclusive OR) operation. Let x, y, and z be any numbers, and XOR has following properties:x XOR 0 is itself, i.e. x XOR 0 = 0;x XOR x is 0, i.e. x XOR x = 0;XOR is associative, i.e. (x XOR y) XOR z = x 阅读全文

posted @ 2014-04-07 02:12 卢泽尔 阅读(194) 评论(0) 推荐(0)

摘要: Problem link:http://oj.leetcode.com/problems/clone-graph/This problem is very similar to "Copy List with Random Pointer", we need a hash map to map a node and its clone.The algorithm is 2-pass procedure as follows.CLONE-GRAPH(GraphNode node): Let MAP be a hash map with pairs of (key=GraphN 阅读全文

posted @ 2014-04-07 01:42 卢泽尔 阅读(274) 评论(0) 推荐(0)