Data Structures & AlgorithmsHardLeetCode-style · Codeforces Div2 C

Starting from [9, 6, 15, 4], repeat 3 times: take the current LARGEST element, replace it by its floor half, and keep the others. What is the sum of the array after these operations?

  1. A. 30
  2. B. 18
  3. C. 31
  4. D. 17

Correct answer: D. 17

Use a max-heap: each operation pops the maximum, halves it, and pushes it back. Halving the smallest element instead (or re-sorting with the wrong sort direction) gives the wrong total.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic