Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: A deque starts as [2, 4, 6]. The operations are: push front 1, push back 8, pop front, push back 3. What is the sum of the final deque?

  1. A. 23
  2. B. 24
  3. C. 16
  4. D. 12

Correct answer: A. 23

[2,4,6] → [1,2,4,6] → [1,2,4,6,8] → pop front → [2,4,6,8] → [2,4,6,8,3], sum 23. Skipping the pop gives 24, popping from the back instead gives 16, and 12 is the untouched starting sum.

More Coding Interview Problems questions

Exams that ask this topic