TS solution with hash map
Approach
Create array of number of bits for unique numbers
Get pair sums, add to hashmap
Complexity
Time complexity:
O(N2)
Code
# Approach
1. Create array of number of bits for unique numbers
2. Get pair sums, add to hashmap

# Complexity
- Time complexity:
O(N2)

# Code
```typescript []
function countExcellentPairs(nums: number[], k: number): number {
    // Get number of set bits
    const getBits = (num: number): number => 
        (num.toString(2).match(/1/g) ?? []).length;

    // Create set of unique numbers
    // Map set to number of bits array and sort it
    const set = new Set<number>();
    const bits: number[] = [];
    nums.forEach((num) => {
        if(!set.has(num)) {
            bits.push(getBits(num));
            set.add(num);
        }
    });
    bits.sort((a, b) => a - b);

    // Map for checked number of bits
    const resMap = new Map<number, number>()

    // Get result from mapped lengths array
    let result = 0;
    
    for(let i = 0; i < bits.length; i++) {
        let count = resMap.get(bits[i]);
        if(count !== undefined) {
            result += count;
            continue;
        }

        if(bits[i] >= k - 1) {
            result += (bits.length * (bits.length - i));
            break;
        }

        for(let j = 0; j < bits.length; j++) {
            if(bits[j] + bits[i] >= k) {
                count = (bits.length - j);
                break;
            }
        }

        result += (count ?? 0);
        resMap.set(bits[i], count ?? 0);
    }

    return result;
};
```
['TypeScript']