Problem · Array
Count Pairs
Learn this problemProblem statement
Given an array of positive integers a, your task is to count the
number of pairs i and j (where 0<= i < j < a.length),
such that a[i] and a[j] have the same number of 1s in their
binary representations.
Function
countPairs(a: int[]) → intExamples
Example 1
a = [3, 5, 1, 7, 8, 10, 62, 13]return = 5
see image
Constraints
N/A (If you know about it, feel free to contact us. TYVM!)
More Roblox problems
- Most Frequent Call Stack Per ThreadPHONE SCREEN · Seen Jul 2026
- Break a PalindromeOA · Seen Jun 2026
- Candy Crush Grid Matching and GravityPHONE SCREEN · Seen Jun 2026
- Closest Binary Search Tree Value — Base PracticePHONE SCREEN · Seen Jun 2026
- Design Search Autocomplete SystemPHONE SCREEN · Seen Jun 2026
- Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · Seen Jun 2026
- Maximize Distance to Closest Person — Return the SeatONSITE INTERVIEW · Seen Jun 2026
- Maximum Number of Balls in a BoxPHONE SCREEN · Seen Jun 2026