1356. Sort Integers by The Number of 1 Bits
https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits
Description
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.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= arr.length <= 500
0 <= arr[i] <= 10^4
ac
Last updated