Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: The array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] is reduced by repeatedly removing the first two elements and appending their sum to the end, until one element remains. What is that element?

  1. A. 175
  2. B. 55
  3. C. 19
  4. D. 3

Correct answer: B. 55

Each round preserves the total, so the survivor is 1 + … + 10 = 55. 175 adds up all the appended sums, 19 is the sum of the last two originals, and 3 is the first appended value.

More Coding Interview Problems questions

Exams that ask this topic