Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: A stack-based bracket checker reads the string "([]{()})[" and reports the number of unmatched opening brackets at the end (0 if the string is fully matched).

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

Correct answer: B. 1

Push openers and pop on matching closers; whatever remains on the stack is unmatched. Here the trailing '[' is the only unmatched opener.

More Coding Interview Problems questions

Exams that ask this topic