Write a code for determining the given integer is palindrome in binaries.
Antwoorden op sollicitatievragen
Anoniem
5 okt 2010
Reverse the bit of the given integer. Then compare it with the original.
Anoniem
19 okt 2010
int palin(int x){
int i, j, flag=0;
i=15; j = 17; /* assuming 32 bit integer */
while( x&(1<
Anoniem
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
Anoniem
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)