Tap here to switch tabs
Problem
Submissions

Problem: Sort Integers by The Number of 1 Bits

Try to solve the Sort Integers by The Number of 1 Bits problem.

Statement

Given an integer array arr, sort the integers in ascending order based on the number of 11’s in their binary representation. If multiple integers share the same count of 11’s, sort them in ascending numerical order.

Return the sorted array.

Constraints:

  • 1≤1 \leq arr.length ≤500\leq 500

  • 0≤0 \leq arr[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sort Integers by The Number of 1 Bits

Try to solve the Sort Integers by The Number of 1 Bits problem.

Statement

Given an integer array arr, sort the integers in ascending order based on the number of 11’s in their binary representation. If multiple integers share the same count of 11’s, sort them in ascending numerical order.

Return the sorted array.

Constraints:

  • 1≤1 \leq arr.length ≤500\leq 500

  • 0≤0 \leq arr[i] ≤104\leq 10^4