Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Each operation doubles one element of [4, 8, 16, 2]. What is the minimum number of operations needed to make all four elements equal?

  1. A. 10
  2. B. 3
  3. C. 14
  4. D. 6

Correct answer: D. 6

Doubling can only raise values, so the cheapest common target is the maximum, 16: 4 needs 2, 8 needs 1, 2 needs 3, total 6. Aiming one power higher (32) costs 10, 3 counts elements rather than operations, and 14 adds 1 each time (16 − 2) instead of doubling.

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

Exams that ask this topic