← All problemsSign in

Friendship Test

Alice and Bob are best friends.  But John has a doubt about their friendship. He wanted to test that.  So he asked them a problem which goes as follows. There are N numbers, they can choose any two numbers and apply AND operation on them.  They need to tell the maximum sum of ANDs possible by selecting distinct pairs.  For example numbers are [10, 10, 20] the possible distinct pairs are {

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