문제를 이해하고 있다면 바로 풀이를 보면 됨
전체 코드로 바로 넘어가도 됨
마음대로 번역해서 오역이 있을 수 있음
주어진 32비트 정수를 뒤집어라.
#1
Input: n = 43261596
Output: 964176192
Integer Binary 43261596 00000010100101000001111010011100 964176192 00111001011110000010100101000000
#2
Input: n = 2147483644
Output: 1073741822
Integer Binary 2147483644 01111111111111111111111111111100 1073741822 00111111111111111111111111111110
class Solution {
public int reverseBits(int n) {
int result = 0;
for(int i = 0; i < 32; i++){
int bit = n & 1;
result = (result << 1) | bit;
n = n >>> 1;
}
return result;
}
}