|
@@ -0,0 +1,16 @@
|
|
|
|
|
+package A
|
|
|
|
|
+
|
|
|
|
|
+import "math/bits"
|
|
|
|
|
+
|
|
|
|
|
+func reverseBits(n int) int {
|
|
|
|
|
+ res := 0
|
|
|
|
|
+ for i := 0; i < 32; i++ {
|
|
|
|
|
+ res = (res << 1) | (n & 1)
|
|
|
|
|
+ n >>= 1
|
|
|
|
|
+ }
|
|
|
|
|
+ return res
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func reverseBits2(n int) int {
|
|
|
|
|
+ return int(bits.Reverse32((uint32(n))))
|
|
|
|
|
+}
|