Data Structures & AlgorithmsVery hard

In the string "((a)(b(c)))d((e))", what is the maximum nesting depth of round brackets (the number of brackets open at the deepest point)?

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

Correct answer: A. 3

Track the current open count while scanning and record its maximum; the answer is the peak depth, not the number of brackets. Counting all open brackets or the final depth misses the nesting structure.

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

Exams that ask this topic