LeetCode 190. Reverse Bits

来源:互联网 发布:java运行库安装 编辑:程序博客网 时间:2024/05/24 05:03
public class Solution {    // you need treat n as an unsigned value    public int reverseBits(int n) {        int r = 0;        for (int i = 0; i < 32; i++) {        r += n & 1;        n >>>= 1;        if (i < 31) r <<= 1;        }        return r;    }}

0 0
原创粉丝点击