1. Shift Out, Shift In Optimal
Intuition
Reversing is a mirror: bit i of n goes to bit 31 - i of the answer, so 4 = 100, whose one set bit is bit 2, becomes bit 29, 536870912. The places need no working out. Take n's last bit, make room in the answer by shifting it left, put the bit in, and shift n right: the first bit taken climbs one place every round after it, so after 32 rounds it is bit 31, and every bit is where the mirror puts it. Then read the answer signed. Bit 31 is the sign bit: Java's int reads it that way by itself, and Python's int has no 32-bit limit, so an answer of 2^31 or more has 2^32 taken off. 11 = 1011 becomes 11010000000000000000000000000000, which is 3489660928 read unsigned and -805306368 read signed. Shift each bit off the input's low end and onto the answer's low end.
Algorithm
1. Start the result at 0.
2. 32 times: shift the result left by one and OR in n's last bit, n & 1; then shift n right by one (in Java, >>>).
3. Return the result read signed: in Java it already is; in Python, take 2^32 off a result of 2^31 or more.
Time & Space
Time O(1): always 32 rounds. Space O(1).