Google Online Assesment Question

Правка en2, от FifthThread, 2021-07-25 08:56:01

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?

Теги #google, #internship

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский FifthThread 2021-07-25 08:56:01 4 Tiny change: 'slots( 2*K<=N). Each ' -> 'slots( 2*K>\n=N). Each '
en1 Английский FifthThread 2021-07-24 22:51:00 604 Initial revision (published)