FastPrepMatch an XOR-Adjusted Sum
Problems/Match an XOR-Adjusted Sum

Match an XOR-Adjusted Sum

Squarepoint Capital logoSquarepoint Capital● HardNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Squarepoint Capital online assessment. The detailed approach matches sum(ai XOR x) to a target by tracking bit carries. Its linked card describes stack reversal instead. We set a clear bit width, a finite range of inputs, and a yes-or-no answer about whether a match exists. Our version is about 65% the same as the reported question.

Determine whether there is an integer x such that 0 <= x < 2^bitWidth and the sum of values[i] XOR x over every array position equals target.

Use the same x for every position. Return true if any such value exists, and false otherwise.

For this exercise, assume the bit width is supplied explicitly, all values fit in that width, and only existence is required. The sum uses signed 64-bit arithmetic.

Function

hasXorAdjustedSum(values: int[], target: long, bitWidth: int) → boolean

Examples

Example 1

values = [1,2]target = 3bitWidth = 2return = true

Choose x = 0. The XOR values stay 1 and 2, whose sum is 3.

Example 2

values = [0,0]target = 1bitWidth = 2return = false

Both XOR values equal x, so their sum is 2*x and cannot be the odd target 1.

Example 3

values = [1]target = 6bitWidth = 3return = true

Choose x = 7, which fits in three bits. Then 1 XOR 7 = 6.

Constraints

  • 1 <= values.length <= 60.
  • 1 <= bitWidth <= 30.
  • 0 <= values[i] <= 1073741823, and every value is smaller than 2^bitWidth.
  • 0 <= target <= 1000000000000.

More Squarepoint Capital interview questions

  • Evaluating Circuit ExpressionsOA · Seen Jul 2026
  • Maximize Palindromic WordsOA · Seen Oct 2025
  • Minimize the Sum with Ceiling HalvesOA · Seen Oct 2025
  • Longest Increasing Subsequence from Two ArraysOA · Seen Oct 2025
  • Resolve Overlapping Price RangesOA · Seen Dec 2024
  • Empty ShelfOA · Seen Sep 2024
  • Suggested ProductsOA · Seen Sep 2024
  • Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
  • Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
  • Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Minimum Operations To Reduce To ZeroUber · OAUber interview questions
  • Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
  • Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
  • Maximum Signal Walk in a Server TreeTower Research Capital · OA
  • Maximum Index-Weighted Sum with Disjoint SwapsVisa · OAVisa interview questions
  • Count Nondecreasing Digit-Sum ArraysMicrosoft · OAMicrosoft interview questions
  • Submask Sum QueriesIntuit · OAIntuit interview questions
  • Distinct Bitwise-OR Scores of Increasing SubsequencesWalmart · OAWalmart interview questions
  • Profitable Currency Exchange CycleOptiver · OAOptiver interview questions
  • Count Valid A-B-C Sequences Under a Modulo-Four RuleInfosys · OAInfosys interview questions

Interview reports that mention this question

  • Squarepoint Capital C++ and Python SWE Interviews: 7 Experiences

Squarepoint Capital interview experiences

  • Squarepoint Campus SDE Interviews: 7 Experiences (Part 2 of 2)
  • Squarepoint Capital New Grad SDE OA: 5 Experiences (Part 1 of 2)
All Squarepoint Capital interview questionsSee Squarepoint Capital hiring insights
Saved
class Solution {
    public boolean hasXorAdjustedSum(int[] values, long target, int bitWidth) {
        // write your code here
    }
}
Checking account…