O(n) Solution |  Explaination | Simple Set-theory solution
A very basic set theory principle states that for an overlapping set, the following holds true\n\t\t\tn ( P \u222A Q ) = n(P) + n(Q) \u2013 n ( P \u2229 Q)\n\t\
A very basic set theory principle states that for an overlapping set, the following holds true\n\t\t\t**n ( P \u222A Q ) = n(P) + n(Q) \u2013 n ( P \u2229 Q)**\n\t\t\twhere n() represent the size of set\n\nnow if we consider all the numbers as a set itself with each of its one bit as its element, \nthen the question is basically asking ask to find the number of pairs of (P, Q) such that **n ( P \u222A Q )+n ( P \u2229 Q) >= k**, \nwhich using set theory principle easily translates to finding pairs such that  **n(P)+n (Q) >= k**\n\nIn our case, n(P) is nothing but number of set bits in P. \n\nLet me know if there is some doubt\n**Golang**\n```\nfunc countExcellentPairs(nums []int, k int) int64 {\n  count := [32]int{}\n  m := map[int]bool{}\n  for i:= 0;i<len(nums);i++{\n    if m[nums[i]]{\n      continue\n    }\n    m[nums[i]] = true\n    l := bits.OnesCount(uint(nums[i]))\n    count[l]++\n  }\n  res := 0\n  for i:= 0;i<=31;i++{\n    if i+i >=k{\n    res += count[i]*count[i]}\n    for j:= i+1;j<=31;j++{\n      if i+j>=k {\n        res += 2*count[i]*count[j]\n      }\n    }\n  }\n  return int64(res)\n}\n```
['Ordered Set', 'Go']