Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Ask the number 0 and save the result in <code>base</code>.
Ask <code>2<sup>i</sup></code> for <code>0 <= i < 30</code>.
If the result is greater than <code>base</code> for some <code>i</code>, then this bit is a set bit in <code>n</code>.
What can be done to revert the effect of the <code>XOR</code>.
Doing <code>XOR</code> again with the same number reverts the effect.