You are given an array A of N integers. Your task is to implement a sorting algorithm that arranges the numbers in the array based on following conditions and return that array:
1. Numbers with an even count of set bits should appear first in ascending order.
2. Following that, numbers with an odd count of set bits should be arranged in ascending order.
Input Format:
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
The first line contains T denoting the number of test cases. T also specifies the number of times you have to run the solve function on a different set of inputs.
For each test case:
Output Format:
For each test case, print the answer in a new line.
Constraints:
1≤T≤101≤N≤1051≤A[i]≤105
Given the input array [5, 2, 8, 12, 7, 6], the output should be [5, 6, 12, 2, 7, 8], as:
Numbers with an even count of set bits: 5(101), 6(110), 12(1100)
Numbers with an odd count of set bits: 2(10), 7(111), 8(100)