FastPrepSum of XOR Across Cartesian Pairs
Problems/Sum of XOR Across Cartesian Pairs

Sum of XOR Across Cartesian Pairs

IBM logoIBM● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IBM online assessment. The report does not give the function signature or the limits on the numbers. Our version is about 97% the same as the reported question.

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[]) → long

Examples

Example 1

left = [1,2]right = [3,4]return = 14

The 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 = 7

The pair values are 0 XOR 7 = 7 and 7 XOR 7 = 0.

Constraints

  • 1 <= left.length, right.length <= 20000
  • 0 <= 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

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public long sumPairXor(int[] left, int[] right) {
        // Write your code here
    }
}
Checking account…