Practice Number of Excellent Pairs
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Count ordered value pairs (a,b) where both values occur in nums and popcount(a OR b) + popcount(a AND b) is at least k. Count each value pair once regardless of duplicate occurrences. Pairs (a,a) are allowed with a single occurrence; (a,b) and (b,a) are different when a differs from b. popcount counts the binary one-bits of its argument.
Source: Number of Excellent Pairs on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [1,2,3,1], k = 3
5
# Example 2
nums = [5,1,1], k = 10
0
Constraints
Related LeetCode Problems
Practice more problems similar to Number of Excellent Pairs.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.