Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: The sum of the numbers obtained by repeatedly removing the first and last elements of [1, 2, 3, 4, 5, 6, 7, 8] and adding them as a pair, across all rounds (4 rounds), is what value?

  1. A. 36
  2. B. 9
  3. C. 4
  4. D. 72

Correct answer: A. 36

Each round adds an outer pair summing to 9 (1+8, 2+7, 3+6, 4+5), so 4 × 9 = 36, the total of the array. 9 is one round, 4 counts rounds, and 72 counts each pair twice.

More Coding Interview Problems questions

Exams that ask this topic