Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

What is the number of unmatched '(' characters in the string "(()())(()" after the standard left-to-right matching?

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

Correct answer: C. 1

Scan with a counter: '(' increments, ')' decrements only when positive. The final counter is the number of unmatched openings.

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

Exams that ask this topic