Given an integer array nums and two integers target1 and target2, find the number of ways to partition nums into one or more contiguous non empty subarrays such that the bitwise XOR sum of the elements in each subarray alternates between target1 and target2.
Specifically, the partition must satisfy the following conditions:
The first subarray has a bitwise XOR sum equal to target1.
The second subarray, if present, has a bitwise XOR sum equal to target2.
The third subarray, if present, has a bitwise XOR sum equal to target1, and the values continue alternating in this pattern for all subsequent subarrays.
Return the total number of valid alternating XOR partitions.
Constraints:
nums.length
nums[i], target1, target2
target1 target2
Given an integer array nums and two integers target1 and target2, find the number of ways to partition nums into one or more contiguous non empty subarrays such that the bitwise XOR sum of the elements in each subarray alternates between target1 and target2.
Specifically, the partition must satisfy the following conditions:
The first subarray has a bitwise XOR sum equal to target1.
The second subarray, if present, has a bitwise XOR sum equal to target2.
The third subarray, if present, has a bitwise XOR sum equal to target1, and the values continue alternating in this pattern for all subsequent subarrays.
Return the total number of valid alternating XOR partitions.
Constraints:
nums.length
nums[i], target1, target2
target1 target2