Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B

What is the minimum number of brackets that must be inserted into ())(()(( to make it a balanced sequence?

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

Correct answer: A. 4

Track open brackets and unmatched closes separately: each unmatched ')' needs an insertion of '(' before it, and each remaining '(' needs a ')' at the end.

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

Exams that ask this topic