Easy-题目43:190. Reverse Bits

转载 2016年05月30日 20:33:03

题目原文:
Reverse bits of a given 32 bits unsigned integer.

For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110000010100101000000).
题目大意:
对一个32位的无符号整数,翻转它的比特位。
题目分析:
用一个新数t从0开始记录n的最后一位,然后令n右移,t左移。
源码:(language:c)

uint32_t reverseBits(uint32_t n) {
    int t=0;
    for(int i=0;i<32;i++) {
        t=t*2+n%2;
        n/=2;
    }
    return t;
}

成绩:
4ms,beats 10.63%,众数4ms,89.37%

相关文章推荐

190. Reverse Bits [easy] (Python)

题目链接https://leetcode.com/problems/reverse-bits/题目原文 Reverse bits of a given 32 bits unsigned integ...

LeetCode(190) Reverse Bits

题目如下: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represe...

190. Reverse Bits\331. Verify Preorder Serialization of a Binary Tree

Reverse Bits description implementation Verify Preorder Serialization of a Binary Tree description i...

[LeetCode][190][Reverse Bits]

题目链接:

【LeetCode-190】 Reverse Bits(C++)

题目要求:要求将一个32位无符号整数所对应的二进制位反转得到的无符号整数。 解题思路:一般这种对应于二进制位的题目要考虑位运算!!而我可能对于位运算不太熟悉,每次都是用最愚蠢的办法做,虽然AC了,但是...

Codeforces Round #190 (Div. 2) E. Ciel the Commander 题目与题解翻译

E. Ciel the Commander time limit per test 1 second memory limit per test 256 megabytes input s...

Leetcode - Reverse Bits

Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in b...

【LeetCode】Reverse Bits 翻转二进制

题目Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input ...

[LeetCode]Reverse Bits

QuestionReverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represen...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)