Domanda di colloquio di Amazon

Write a code for determining the given integer is palindrome in binaries.

Risposte di colloquio

Anonimo

5 ott 2010

Reverse the bit of the given integer. Then compare it with the original.

Anonimo

19 ott 2010

int palin(int x){ int i, j, flag=0; i=15; j = 17; /* assuming 32 bit integer */ while( x&(1<

Anonimo

15 feb 2011

Add to the candidate. Reverse all the bits by exchanging adjacent bits, adjacent two bits, adjacent four bits, etc...O(log n).. n is the number of bits in the number Then XOR with original, to see if result is 0, otherwise not palindrome

Anonimo

21 feb 2011

import os,sys def is_palindrome(x): t=x; cnt=0; while t>0: print t t>>=1; cnt+=1; print cnt; for i in range(cnt/2): if ((x & (1 0) != ((x & (1 0): return False return True print is_palindrome(5)