You are given an array A of N non negative integers. There are K empty slots from 1 to K. You have to arrange these N numbers into K slots( 2*K<=N). Each slot can contain at most two numbers filled into it. After all the integers have been placed into these slots, find the sum of bitwise AND of all the numbers with their respective slot numbers
Task: Determine the maximum possible sum
Note: Some slots may remain empty
Example A = [1,3,10,20,7,1] N = 5 K = 10 answer = 25
I did brute force and some test case passed.
How to do this question?