Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: A stack starts with the characters pushed in the order a, b, c, d. The following pops occur: pop, pop, then push e, pop. Which character is at the top of the stack at the end?

  1. A. a
  2. B. c
  3. C. d
  4. D. b

Correct answer: D. b

After popping d and c the stack holds a, b; pushing e and popping it leaves b on top. Mistaking the top for the first pushed item gives a.

More Coding Interview Problems questions

Exams that ask this topic