Data Structures & AlgorithmsHardTCS NQT · Accenture

Problem: The minimum number of characters to delete from "(()))(" to make the parentheses balanced (every ( has a matching ) after it) is what value?

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

Correct answer: D. 2

Scan left to right: an unmatched ')' must be deleted, and any unmatched '(' left at the end must also go. Adding only the unmatched closing brackets undercounts.

More Coding Interview Problems questions

Exams that ask this topic