// Reverse bits of a given 32 bits. // The input must be a binary string of length 32 // Example : input: n = 00000010100101000001111010011100, Output: 964176192 (00111001011110000010100101000000) - reversed.
function reverseBits($n) {
    $n = bindec(strrev($n));
    return $n;
}
echo reverseBits("00000010100101000001111010011100");
// P.S onlinephp returns correct answer: 964176192, but
// leet code returns 1 at the same case,
// can someone explain to me in the comments ? 
by Luka Khitaridze
2 years ago
PHP
String
1
Pro tip: use ```triple backticks around text``` to write in code fences