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!)