[Python] Easy to understand 2-pointer solution w explanation
The key part for the quesiton is to understand the value The sum of the number of set bits in num1 OR num2 and num1 AND num2 is actually the sum of count of 1 i
The key part for the quesiton is to understand the value `The sum of the number of set bits in num1 OR num2 and num1 AND num2` is actually the sum of count of 1 in bit representative of 2 number\nThen if we change the array to be counts of 1 in bit representative of each number, sort the array,  it change to a 2-pointer question.\nWe could first consider the counts of paris formed by different number, then consider the pairs formed by same number \n``` Python\n        \nclass Solution:\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:\n        A  = sorted([bin(n).count(\'1\') for n in set(nums)])\n        res = 0\n        p1, p2 = 0, len(A) - 1\n        while p1 < p2:\n            if A[p1] + A[p2] >= k:\n                res += (p2 - p1) * 2 # *2 because it can be either (a, b) or (b,a)\n                p2 -= 1\n            else:\n                p1 += 1\n        \n        for n in A:\n            if 2 * n >= k:\n                res += 1\n        return res\n        \n```
['Two Pointers', 'Python']