Sunday, September 30, 2012

You have given n numbers from 1 to n. You have to sort numbers with increasing number of set bits.

for ex: n=5.
output: 1,2,4,3,5
Note: If you have two number with equal number of set bits, then number with lowest value come first in the output.

No comments :