Data Structures & AlgorithmsHardGATE CS · TCS NQT

In one move you may increment all elements of an array except one by 1. What is the minimum number of moves to make all elements of [1, 5, 7, 3] equal?

  1. A. 6
  2. B. 12
  3. C. 13
  4. D. 11

Correct answer: B. 12

Each move is equivalent to decrementing one element relative to the others, so every element must drop to the minimum 1. The total is sum minus n times the minimum: 16 - 4 = 12.

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

Exams that ask this topic