Bitwise operators - hackerearth problem

Problem - https://www.hackerearth.com/practice/basic-programming/bit-manipulation/basics-of-bit-manipulation/practice-problems/algorithm/sorting-1-581e9aa0/

My solution - https://ide.codingblocks.com/s/45244

The first and the fifth test case pass while others fail.

Hey Tarun, its given in the ques In case of same no. of ON bits, the smallest index will take place first. Most probably when you are sorting the array if elements are having same count of bits then they are not sorted on the basis of their indexes in the input array.