Given 2 numbers. Find if they are consecutive grey code sequences
Anonymous
public static int isGrayCode(int n1, int n2) { int x = n1^n2; int nbits = 0; while (x != 0) { if (nbits > 1) return 0; nbits += (x & 1); x >>= 1; } return nbits==1? 1:0; }
Check out your Company Bowl for anonymous work chats.