2016年7月5日

摘要: Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your al 阅读全文
posted @ 2016-07-05 10:59 codingEskimo 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(123) 评论(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 阅读(135) 评论(0) 推荐(0) 编辑

导航