Leetcode 190 Reverse Bits 位运算
反转二进制
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t ans = ;
for (int i = ; i<; ++i,n >>=){
ans = (ans<< )|(n & );
}
return ans;
}
};
Leetcode 190 Reverse Bits 位运算的更多相关文章
- LeetCode 190. Reverse Bits (算32次即可)
题目: 190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432 ...
- [LeetCode] 190. Reverse Bits 颠倒二进制位
Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 ...
- [LeetCode] 190. Reverse Bits 翻转二进制位
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- LeetCode 190. Reverse Bits (反转位)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Java for LeetCode 190 Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Leetcode 190. Reverse Bits(反转比特数)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Java [Leetcode 190]Reverse Bits
题目描述: everse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represente ...
- 【LeetCode】190. Reverse Bits 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 二进制字符串翻转 位运算 日期 题目地址:https://le ...
- 【LeetCode】190. Reverse Bits
题目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented ...
随机推荐
- javascript 中break、 continue、函数不能重载
在javascript中,break与continue有着显著的差别. 如果遇到break语句,会终止最内层循环,无论后面还有多少计算. 如果遇到continue,只会终止此次循环,后面的自循环依然执 ...
- iOS7.0适配问题
self.navigationController.navigationBar.translucent = YES,导航栏透明 extendedLayoutIncludesOpaqueBars = Y ...
- 小甲鱼python视频第十讲(课后习题)
1.list1[0]与list1[0:1]的区别 2.分片的步长 3关于列表的copy(注意list2与list3的区别) list1 = [,,,,,,] list2 = list1[:] list ...
- tp 中关于大小写的问题
ThinkPHP3.2.3升级的若干问题和注意事项(持续更新) 现把ThinkPHP3.2.2在升级到3.2.3的过程中需要注意和可能的问题整理如下: (无论如何,在升级之前请确认备份) 1.首先3. ...
- 20145225《Java程序设计》 实验五 Java网络编程及安全
20145225<Java程序设计> 实验五 Java网络编程及安全 实验报告 一.实验内容 基于Java Socket实现安全传输. 基于TCP实现客户端和服务器,结对编程一人负责客户端 ...
- C++通过模板实现多态
#include <iostream> using namespace std; template<typename T> class Phone { public: void ...
- .net web获取自己的ip地址
using System;using System.Text;using System.Web;using System.Text.RegularExpressions; namespace MxWe ...
- 四色定理+dfs(poj 1129)
题目:Channel Allocation 题意:要求A:BCD,A与B,C,D都不相同,求不同的值,典型的四色定理: #include <iostream> #include <a ...
- Big Event in HDU(HDU1171)可用背包和母函数求解
Big Event in HDU HDU1171 就是求一个简单的背包: 题意:就是给出一系列数,求把他们尽可能分成均匀的两堆 如:2 10 1 20 1 结果是:20 10.才最均匀! 三 ...
- PHP字符处理基础知识
<?php class StrDemo { function StrTest() { $s = "abcd"; print '$s length:'.strlen($s).& ...