← All problemsSign in

3811. Number of Alternating XOR Partitions

LeetCodeArrayHash TableDynamic ProgrammingBit ManipulationOpen on judge ↗

You are given an integer array nums and two distinct integers target1 and target2. A partition of nums splits 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 target1 and target2, starting with target1. Formally, for blocks b1, b2, …: - XOR(b1) = target1 - XOR(b2)

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start