Maximum XOR subset

Write codeHard35 min

Your task

Given an array nums of non-negative integers (each fits in 32 bits, up to 1000 elements), choose any subset (possibly empty) and XOR its elements together. Return the maximum XOR value achievable over all subsets. The empty subset gives 0. For example, from [3, 8, 12] the best is 3 XOR 12 = 15.

Examples

max_xor_subset(nums: list[int]) -> int
Example 1
Inputmax_xor_subset([3, 8, 12])
Output15