码迷,mamicode.com
首页 >  
搜索关键字:bits    ( 3873个结果
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 ...
分类:其他好文   时间:2015-04-13 09:30:41    阅读次数:102
LeetCode—Reverse Bits ,1 Bit和数字的二进制情况相关
https://leetcode.com/problems/reverse-bits/ Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), ret...
分类:其他好文   时间:2015-04-13 00:26:40    阅读次数:143
[LeetCode]191.Number of 1 Bits
题目Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 00000000000...
分类:其他好文   时间:2015-04-12 21:12:01    阅读次数:130
Leetcode Reverse Bits
题目地址:https://leetcode.com/problems/reverse-bits/题目分析:可以4bit为单位,0翻转对应0,1翻转对应8.....15翻转对应15,将这些翻转信息保存在数组中即可以O(1)的空间复杂度换来很好的时间复杂度题目解答:public class Soluti...
分类:其他好文   时间:2015-04-11 17:46:15    阅读次数:113
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...
分类:其他好文   时间:2015-04-11 16:25:26    阅读次数:127
191 Number of 1 Bits
最近想刷一下LeetCode练习一下数据结构算法之类的,先从水题开始吧题目是这样的Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theH...
分类:其他好文   时间:2015-04-10 13:11:14    阅读次数:117
LeetCode Reverse Bits 反置位值
题意:给定一个无符号32位整数,将其二进制形式左右反置,再以整型返回。思路:循环32轮,将n往右挤出一位就补到ans的尾巴上。 1 class Solution { 2 public: 3 uint32_t reverseBits(uint32_t n) { 4 if( !n...
分类:其他好文   时间:2015-04-10 01:07:34    阅读次数:109
LeetCode Number of 1 Bits 计算1的个数
题意:提供一个无符号32位整型uint32_t变量,返回其二进制形式的1的个数。思路:取出一位,就右移1位,挤掉它,循环32次,逐个判断。没难度就不解释了,可能有更好解法,等待第2次思考。 1 class Solution { 2 public: 3 int hammingWeight(ui...
分类:其他好文   时间:2015-04-09 23:27:32    阅读次数:115
fd_set的具体实现过程
fd_set的实现详细原理 define FD_SETSIZE 1024 typedef unsigned long fd_mask; #define NBBY 8 /* number of bits in a byte */ #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mas...
分类:其他好文   时间:2015-04-09 17:29:53    阅读次数:149
leetcode_Number of 1 Bits
思路: java中如何表示无符号整数呢,很伤,那就用C写吧。二进制与运算和二进制循环移位搞定...
分类:其他好文   时间:2015-04-08 21:39:43    阅读次数:139
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!