[leetcode] Reverse Bits
Reverse Bits
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).
Follow up:
If this function is called many times, how would you optimize it?
Related problem: Reverse Integer
Special thanks to @ts for adding this problem and creating all test cases.
class Solution
{
public:
uint32_t reverseBits(uint32_t n)
{
int A[] = {};
int i = ;
while(n > )
{
A[i++] = n % ;
n /= ;
} int sum = ;
for(i = ; i < ; i++)
sum = sum * + A[i]; return sum;
}
};
[leetcode] Reverse Bits的更多相关文章
- 2016.5.16——leetcode:Reverse Bits(超详细讲解)
leetcode:Reverse Bits 本题目收获 移位(<< >>), 或(|),与(&)计算的妙用 题目: Reverse bits of a given 3 ...
- [LeetCode] Reverse Bits 翻转位
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- leetcode reverse bits python
Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (re ...
- LeetCode Reverse Bits 反置位值
题意:给定一个无符号32位整数,将其二进制形式左右反置,再以整型返回. 思路:循环32轮,将n往右挤出一位就补到ans的尾巴上. class Solution { public: uint32_t r ...
- [LeetCode] Reverse Bits 位操作
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- lc面试准备:Reverse Bits
1 题目 Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represente ...
- LeetCode 190. Reverse Bits (反转位)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- 【一天一道Leetcode】#190.Reverse Bits
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 我的个人博客已创建,欢迎大家持续关注! 一天一道le ...
- [LeetCode] 190. Reverse Bits 颠倒二进制位
Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 ...
随机推荐
- visual studio 2012 has stopped working
I had similar problem which was resolved by taking two steps : 1A. DELETE THE REGISTRY KEY : 32-bit ...
- windows下mysql远程访问慢
在my.conf中加入 skip-name-resolve
- spring 配置多个数据源的文件
<?xml version="1.0" encoding="UTF-8"?><!-- Repository and Service layer ...
- 利用 ELK系统分析Nginx日志并对数据进行可视化展示
一.写在前面 结合之前写的一篇文章:Centos7 之安装Logstash ELK stack 日志管理系统,上篇文章主要讲了监控软件的作用以及部署方法.而这篇文章介绍的是单独监控nginx 日志分析 ...
- .NET 配置文件简单使用
当我们开发系统的时候要把一部分设置提取到外部的时候,那么就要用到.NET的配置文件了.比如我的框架中使用哪个IOC容器需要可以灵活的选择,那我就需要把IOC容器的设置提取到配置文件中去配置.实现有几种 ...
- AccessHelper
代码: using System; using System.Data; using System.Configuration; using System.Data.OleDb; using ahwi ...
- appt查看apk信息
aapt dump badging app-debug.apk
- 一个App的界面设计流程是怎么产生的
作者:候佩雯链接:http://www.zhihu.com/question/27088793 完整的流程,分层次设计,自下而上去完成: 策略层,定义产品使命.价值.目标人群 愿景/功能层:定义核心场 ...
- 进入IT企业必读的200个.NET面试题
点击打开链接 点击打开链接 版权声明:本文为博主原创文章,未经博主允许不得转载.
- YEdit
YEdit YEdit is a YAML editor for Eclipse. See the wiki for more details Installation Use the Eclipse ...