Data Structures & AlgorithmsHardCodeforces Div2 B · TCS NQT

You may increase any element of [5, 3, 2, 10, 4] by any amount (increases only). What is the minimum total increase needed to make the array strictly increasing?

  1. A. 17
  2. B. 26
  3. C. 15
  4. D. 14

Correct answer: C. 15

Scan left to right and raise each element to exactly one more than the previous value when needed; raising more than necessary only adds cost, and the greedy target is always feasible. Summing all gaps to the maximum does not respect the order constraint.

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

Exams that ask this topic