随笔分类 -  位操作

摘要:Given an array of numbersnums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements t... 阅读全文
posted @ 2015-08-18 23:45 丶Blank 阅读(1423) 评论(0) 推荐(0)
摘要:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题目大意:不用乘除取模运算计算两个数的除。解题思路:只能用位运算了,当被除数大于... 阅读全文
posted @ 2015-05-19 19:33 丶Blank 阅读(150) 评论(0) 推荐(0)
摘要:Given a range [m, n] where 0 offset = new HashSet(); for (int i = 0; i >=1; n>>=1; offset++; } return m<<o... 阅读全文
posted @ 2015-04-20 17:42 丶Blank 阅读(1362) 评论(0) 推荐(0)
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in... 阅读全文
posted @ 2015-04-20 16:43 丶Blank 阅读(119) 评论(0) 推荐(0)