190. 颠倒二进制位
public class Solution {// you need treat n as an unsigned valuepublic int reverseBits(int n) {int ans = 0;for (int i = 0; i < 32 && n != 0; i++) {ans |= (n & 1) << (31 - i);n = n >>> 1;}return ans;}}
public class Solution {// you need treat n as an unsigned valuepublic int reverseBits(int n) {int ans = 0;for (int i = 0; i < 32 && n != 0; i++) {ans |= (n & 1) << (31 - i);n = n >>> 1;}return ans;}}
让时间为你证明