input is a binary string (32 bit) - n we have to reverse the binary string and print that number.
we can come up with code like this
rev = 0
for i in range(0,32):
rev = (rev<<1) + (n & 1)
n = n>>1
return rev
just wanted to know if we can use the "or" operator instead of "and" something like
rev = (rev<<1) + (n | 0)
I tried this in leetcode IDE but it didnt work im not sure why, does anyone know why this doesn't work? and if you know any. other better approaches to do this, it would be great!