can u please tell me how to handle 64 bit nos
my ans getting wrong coz of that
if possible modify the program
The great xor problem hackerrank
Just set the position of ‘a’ with 1 in the position where x is set with 0 else set ‘a’ with 0.
1 Like
can u go through this code and make the changes
Pls elaborate your approach.
for example n=5
so xoring 5 with values 1,2,3,4 gives me two values which are greater than 5
for example n=4
so xoring 4 with values 1,2,3 gives me 3 values which are greater than 4
so u see the pattern…total bits in n is 3…and the max value u can reach with 3 bits is 7…
now subtract 4 and 5 from 7 u get 3 and 2 respectively thats the ans…so what i tried is find the total bits in n and get the max value and subtract n from it…but it fails for 64 bit numbers