Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: Starting with the list [1, 2, 3, 4, 5, 6], repeatedly remove every second element (keeping the first) until one element remains. Which value is left?

  1. A. 2
  2. B. 1
  3. C. 0
  4. D. 3

Correct answer: B. 1

Each pass keeps the odd positions (indices 0, 2, 4, ...). The survivor is the value at index 0 at the end, and the parity of each list length determines the path.

More Coding Interview Problems questions

Exams that ask this topic