Simple Solution in O(nlog(n)) | CPP| Bits | Set Bit logic
My logic is based on the fact that ,\n\t\t\t   setbit(a | b) = setbit(a) + setbit(b) - setbit(a & b)\n   So,\n\t\t\t   setbit( a&b) + setbit(a|b) = setbit(a) + 
My logic is based on the fact that ,\n\t\t\t   **setbit(a | b) = setbit(a) + setbit(b) - setbit(a & b)**\n   So,\n\t\t\t   **setbit( a&b) + setbit(a|b) = setbit(a) + setbit(b)** \n\t   \n   In the below solution we have tried to make pair of setbit with sum greater than k also we have not considered repeated element as we need unique pair.\n   \n\tint countSetBit(int n){\n        int count = 0;\n        while (n) {\n            count += (n & 1);\n            n >>= 1;\n        }\n        return count;\n    }\n\t\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        vector<int> v(33,0);\n        set<int> st;\n        \n        for(int &x:nums){\n            if(st.find(x)==st.end())\n                st.insert(x);\n            else\n                continue;\n            \n            v[countSetBit(x)]++;\n        }\n        long long ans =0;\n        \n        for(int i=0;i<=32;i++){\n            for(int j=0;j<=32;j++){\n                if(i+j>=k){\n                    ans += (v[i]*1LL*v[j]);\n                }\n            }\n        }\n        return ans;\n    }\n\t\nIf you liked it, Please do upvote.\nIf there are any suggestions / questions / mistakes in my post, comment below \uD83D\uDC47
['C', 'Ordered Set', 'C++']