#3811

Number of Alternating XOR Partitions

expert · 1150 · lc medium +32 · 26.6% accepted · 86 likes · top 5%

Description

Given an integer array nums and two distinct integers target1 and target2, count the ways to partition nums into one or more contiguous non-empty blocks such that the bitwise XOR of successive blocks alternates between target1 and target2 starting with target1 (a single block is valid if its XOR equals target1), returning the count modulo 109 + 7.

Code

1
2
3