Linear Basis Max XOR Problem
Linear Basis Max XOR Problem — ExecCode Hard DSA Practice
Solve the Linear Basis Max XOR problem on ExecCode. Free online hard DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You may XOR any subset of the numbers together. The maximum possible result is found by inserting each number into a Gaussian XOR basis (highest bit first) then greedily XOR-ing the basis from high bits to low. Return that maximum subset XOR. The empty subset is 0. You are given: nums — non-negative integers Return maximum subset XOR. You may use each array element at most once, which the basis already encodes.
Examples
Input {'nums': [1, 2, 3]}; Output 3. Input {'nums': [0, 0]}; Output 0. Input {'nums': [8, 1]}; Output 9
Constraints
Duplicates allowed All zeros → 0
Practice Linear Basis Max XOR free on ExecCode. Browse DSA problems, topic map, and placement guides.