You are viewing a single comment's thread. Return to all comments →
javascript
function flippingBits(n) { let bits = [...n.toString(2).padStart(32, 0)] let flip = bits.map(b => 1 - b).join('') return parseInt(flip, 2) }
version2
function flippingBits(n) { n = n >>> 0 return ~n >>> 0 }
Seems like cookies are disabled on this browser, please enable them to open this website
Flipping bits
You are viewing a single comment's thread. Return to all comments →
javascript
version2