Bit Manipulation
dyllanzhou
这个作者很懒,什么都没留下…
展开
-
[Leetcode]Bitwise AND of Numbers Range
Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4. class Solution { public: /*algorithm : bit manipulation using n&(n-1) to get rid of last 1 */原创 2015-09-01 13:18:37 · 266 阅读 · 0 评论 -
[Leetcode]Single Number II
Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using原创 2015-09-22 14:34:11 · 256 阅读 · 0 评论 -
[Leetcode]Subsets
Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets. For example,原创 2015-10-12 15:48:51 · 329 阅读 · 0 评论 -
[Leetcode]Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm should run原创 2015-09-23 16:57:31 · 279 阅读 · 0 评论 -
[Leetcode]Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gr原创 2015-09-23 18:40:12 · 266 阅读 · 0 评论