Complexity
Time: since we got to loop through all 32 bits
Space:
Notes
Doesn’t really matter here whether >>
does signed right shift since we only care about 32 bits fixed and won’t do any more funny business post that. Output integer varies b/w languages where there is unsigned int type.
Beware of gotchas in langs like JS where the bit shift operators work on 32 bit integers only and returns a 32 bit value, in case question is modified to ask about 64-bit integers