You are viewing a single comment's thread. Return to all comments →
here is my Go solution
func theGreatXor(x int64) int64 { if x & (x - 1) == 0 { return x - 1 } var count uint var temp int64 = x for temp > 0 { temp = temp >> 1 count++ } if count == 0{ return 0 } else{ return 1 << (count - 1) - (x - (1 << (count - 1))) - 1 } }
Seems like cookies are disabled on this browser, please enable them to open this website
The Great XOR
You are viewing a single comment's thread. Return to all comments →
here is my Go solution