All practice tasks

Coding (Algo)

Find the Most Different Mask Pair

Bit manipulation · Hard

A test generator wants the pair of recorded masks with the greatest numeric XOR. It may contain one hundred thousand entries, so comparing all pairs is too expensive. This is a specialist bit-prefix exercise rather than a requirement for every engineering interview.

Return the largest unsigned XOR attainable using two different input indexes.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

{ nums: unsigned32[] }

Fields

  • nums contains unsigned 32-bit integers from 0 through 4294967295. Values with bit 31 set are positive JSON integers.

Output

Return value

  • Return the maximum unsigned XOR value, not the original pair or its indexes.
  • Return null with fewer than two entries. Equal values at different indexes may form a pair whose XOR is zero.

Constraints

  • 0 <= nums.length <= 100000.

Examples

Example 1

{
  "nums": [
    3,
    10,
    5,
    25,
    2,
    8
  ]
}

Returns

28

Example 2

{
  "nums": [
    0,
    4294967295
  ]
}

Returns

4294967295

Required complexity

O(32n) expected time and O(n) auxiliary space using prefix sets

What this task practices

Find the Most Different Mask Pair is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as hard difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.