Data Structures & AlgorithmsHardGATE CS · TCS NQT

A string of brackets is ')))(()(' where '(' opens and ')' closes. What is the minimum number of brackets that must be removed to make the string balanced?

  1. A. 5
  2. B. 6
  3. C. 7
  4. D. 9

Correct answer: A. 5

Unmatched closing brackets are counted when no open bracket is available, and unmatched open brackets remain on the stack at the end; both must be removed.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic