Search
⌘K

Leetcode 1787. Make the XOR of All Segments Equal to Zero

Given an array nums and integer k, find the minimum number of element changes so that every contiguous subarray of length k has XOR equal to zero. Key insight: indices partition into k residue classes (by index mod k), and you choose values for each class to make their XOR zero while minimizing edits — typically solved by DP over XOR states using frequency counts (value domain < 2^10).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.