Given an integer array
arr. You have to sort the integers in the array in ascending order by the number of 1’s in their binary representation and in case of two or more integers have the same number of 1’s you have to sort them in ascending order.
Return the sorted array.
Input: arr = [0,1,2,3,4,5,6,7,8]
It’s a customized sorting problem. But we need to convert
Integer, so that we can sort them.
// time: O(nlogn), space: O(n)