← All problemsSign in

3630. Partition Array for Maximum XOR and AND

LeetCodeArrayMathGreedyBit ManipulationEnumerationOpen on judge ↗

You are given an integer array nums. Partition the array into three (possibly empty) subsequences A, B, and C such that every element of nums belongs to exactly one subsequence. Your goal is to maximize the value of: XOR(A) + AND(B) + XOR(C) where: - XOR(arr) denotes the bitwise XOR of all elements in arr. If arr is empty, its value is defined as 0. - AND(arr) denotes the bitwise AND of all e

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