Stripe's analytics team is studying relationships between values stored in an array.
Given an array values of non-negative integers and a non-negative integer k, determine the number of pairs of indices (i, j) such that i < j and the source bitwise condition holds.
The source condition simplifies to:
values[i] + (values[i] XOR values[j]) = k
Return the total number of valid pairs.
Examples
01 · Example 1
values = [1,2,3] k = 4 return = 1
The only valid pair is (1, 2) using 1-based positions: 1 + (1 XOR 2) = 1 + 3 = 4.
Constraints
1 <= values.length <= 10^50 <= k <= 10^180 <= values[i] <= 10^18- The sum of
values.lengthover all test cases does not exceed3 * 10^5in the original assessment format.
More Stripe problems
- Request Routing SystemOA · Seen May 2026
- Email Log Processing, Grouping, and SortingOA · Seen May 2026
- Generate Available Time SlotsPHONE SCREEN · Seen Apr 2026
- Chat Billing CalculationSeen Mar 2026
- Process List of CommandsSeen Dec 2024
- Card Range Obfuscation Part 2 (ML Eng :)Seen Nov 2024
- Card Range Obfuscation Part 3 (ML Eng :)Seen Nov 2024
- Card Range Obfuscation Part 4 (ML Eng :)Seen Nov 2024
public long countValidBitwisePairs(long[] values, long k) {
// write your code here
}values[1,2,3]
k4
expected1
sign in to submit