Tap here to switch tabs
Problem
Submissions

Problem: Number of Excellent Pairs

Try to solve the Number of Excellent Pairs problem.

Statement

You are given an array of positive integers nums and a positive integer k.

A pair (num1, num2) is defined as excellent if both of the following conditions hold:

  • Both num1 and num2 are present in nums.

  • The sum of the number of set bits in (num1 OR num2) and (num1 AND num2) is greater than or equal to k.

Return the total number of distinct excellent pairs.

Note: Two pairs (a, b) and (c, d) are distinct if a≠ca \neq c or b≠db \neq d.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤60\leq 60

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Excellent Pairs

Try to solve the Number of Excellent Pairs problem.

Statement

You are given an array of positive integers nums and a positive integer k.

A pair (num1, num2) is defined as excellent if both of the following conditions hold:

  • Both num1 and num2 are present in nums.

  • The sum of the number of set bits in (num1 OR num2) and (num1 AND num2) is greater than or equal to k.

Return the total number of distinct excellent pairs.

Note: Two pairs (a, b) and (c, d) are distinct if a≠ca \neq c or b≠db \neq d.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤60\leq 60