prefix_xor
to 0 (the XOR of an empty subarray).result
to 0 to store the number of beautiful subarrays.nums
:
a. Update prefix_xor
with the XOR of the current element.
b. Add the count of prefix_xor
in the counter to result
(since each occurrence represents a subarray ending at the current index that can be made beautiful).
c. Increment the count of prefix_xor
in the counter.result
.