3811. Number of Alternating XOR Partitions
You are given an integer array
numsand two distinct integerstarget1andtarget2.A partition of
numssplits it into one or more contiguous, non-empty blocks that cover the entire array without overlap.A partition is valid if the bitwise XOR of elements in its blocks alternates between
target1andtarget2, starting withtarget1.Formally, for blocks
b1,b2, …:
XOR(b1) = target1XOR(b2) = target2(if it exists)XOR(b3) = target1, and so on.Return the number of valid partitions of
nums, modulo10^9 + 7.Note: A single block is valid if its XOR equals
target1.
1 |
|