MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / reverseBits

Method reverseBits

190-reverse-bits/reverse-bits.java:5–13  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

3public class Solution {
4 // you need treat n as an unsigned value
5 public int reverseBits(int n) {
6 int result = 0;
7 for (int i = 0; i < 32; i++) {
8 result <<= 1;
9 result |= (n & 1);
10 n >>= 1;
11 }
12 return result;
13 }
14}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected