Sum of XOR Across Cartesian Pairs
Updated
Problem statement
Given two arrays of nonnegative integers, left and right, consider every ordered pair (left[i], right[j]).
Return the sum of left[i] XOR right[j] over all such pairs.
Function
sumPairXor(left: int[], right: int[]) → longExamples
Example 1
left = [1,2]right = [3,4]return = 14The four XOR values are 1 XOR 3 = 2, 1 XOR 4 = 5, 2 XOR 3 = 1, and 2 XOR 4 = 6. Their sum is 14.
Example 2
left = [0,7]right = [7]return = 7The pair values are 0 XOR 7 = 7 and 7 XOR 7 = 0.
Constraints
1 <= left.length, right.length <= 200000 <= left[i], right[j] <= 10^9- The answer fits in a signed 64-bit integer.
More IBM Online Assessment questions
- Missing IntervalsOA · Seen Nov 2026
- Count Peaks and ValleysOA · Seen Nov 2026
- Last Object Exit TimeOA · Seen Nov 2026
- Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
- Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
- Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
- Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
- Tree Pythagorean TriplesOA · Seen Oct 2026
- Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
- Maximum Compatible Time WindowsOA · Seen Oct 2026
Similar questions at other companies
- Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
- Repeated Mirror XORMathWorks · OAMathWorks interview questions
- Minimum Power-of-Two Removal OperationsVisa · OAVisa interview questions
- Find the Missing Number from 1 to nGEP · OA
- Bayesian Scenario ClassifierAmazon · ONSITE INTERVIEW
- Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Knights, Knaves and Their StatementsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Stacked Item and Category DiscountsPalantir · OAPalantir interview questions