Explained -Short C++ Solution
The main idea is that any 2 numbers & and | operations set bit count will be equal to the sum of their bit counts.\nWe pre calculated the bit count and saved it
The main idea is that any 2 numbers & and | operations set bit count will be equal to the sum of their bit counts.\nWe pre calculated the bit count and saved it in an array.\nNow we will do the number of pairs greater than k to find the ans in nlog (n) time .\nFor that we will first sort the array and the find the array greater than or equal to k-arr[i] using lower_bound function. all the elements after that element will also be in our answer so we will add arr.size()-j to our answer.\nComplexity - nlog(n)\n```\nlong long countExcellentPairs(vector<int>& nums, int k) {\n        vector<int>arr;\n        set<int>st(nums.begin(),nums.end());\n\n        for(auto i=st.begin();i!=st.end();i++){\n                auto a = *i;\n                int count=0;\n                for(int j=0;j<32;j++){\n                    if(*i & (1<<j))count++;\n                    \n                }\n            arr.push_back(count);\n        }\n        long long ans=0;\n        \n        sort(arr.begin(),arr.end());\n        \n        for (int i = 0; i < arr.size(); ++i) {\n\n        int j = lower_bound(arr.begin(), arr.end(), k-arr[i]) - arr.begin();\n \n\n        ans += arr.size()-j;\n    }\n        \n        return ans;\n    }\n```
['Bit Manipulation', 'C', 'Binary Tree']