Tap here to switch tabs
Problem
Submissions

Problem: Sort Integers by The Number of 1 Bits

Sort Integers by The Number of 1 Bits asks you to sort an integer array by the number of ones in each value’s binary representation, using numerical order to break ties.

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

Sort Integers by The Number of 1 Bits asks you to sort an integer array by the number of ones in each value’s binary representation, using numerical order to break ties.

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