#3599

Partition Array to Minimize XOR

medium · 41.1% accepted · 107 likes · top 21%

array · dynamic programming · bit manipulation · prefix sum

Description

You are given an integer array nums and an integer k.

Your task is to partition nums into k non-empty subarrays. For each subarray, compute the bitwise XOR of all its elements.

Return the minimum possible value of the maximum XOR among these k subarrays.

Solution