JAVA | O(N) | SIMPLE EXPLANATION
EXPLANATION :\nfirst we have to find the unique elements to remove duplicates element,\nthen we have to just count the no of set bits in each element , \nthen w
EXPLANATION :\nfirst we have to find the unique elements to remove duplicates element,\nthen we have to just count the no of set bits in each element , \nthen we have to hashing, \narr[i] will store, the no elements having the set bits equal to, i\n\nthen by using the same array, i calculate the suffix sum,\nnow the definition of array (arr) changes, \ni.e, arr[i] will store, the no elements having the set bits equal to or greater than i,\n\nthen at last, i traverse to all the unique elements,\neach element will make pair with other element only if, the count of set bit of both element will be equal to or greater then K,\n\nso i just again count the sets bit of each element , and update ans with \n int req=Math.max(0,k-c);\n ans+=arr[req];\n \n HAPPY CODING :)\n \n **IF YOU LEARN SOMETHING FROM THIS POST, DO UPVOTE :)**\n\n```\npublic long countExcellentPairs(int[] nums, int k) {\n        \n        Set<Integer> set=new HashSet<>();\n        for(int a:nums){\n            set.add(a);\n        }\n        long arr[]=new long[32];\n        Set<Integer> s1=new HashSet<>();\n        for(Integer a:set){\n            int c=0;\n            while(a!=0){\n                c+=a%2;\n\t\t\t   a/=2;\n            }\n            arr[c]++;\n        }\n        long ans=0;\n        for(int i=30;i>=0;i--){\n            arr[i]+=arr[i+1];\n        }\n        for(Integer a:set){\n            int c=0;\n            while(a!=0){\n               c+=a%2;\n\t\t\t   a/=2;\n            }\n            int req=Math.max(0,k-c);\n            ans+=arr[req];\n        }\n        return ans;\n    }\n\t```
['Java']