Data Structures & AlgorithmsModerateTCS NQT · Infosys

What is the maximum nesting depth of the parentheses in the string a(b(c)d)(e(f(g))) ?

  1. A. 3
  2. B. 4
  3. C. {C-1}
  4. D. 5

Correct answer: A. 3

Track the depth as an opening bracket adds one and a closing bracket removes one; the maximum reached is the nesting depth.

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

Exams that ask this topic