Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many well-formed strings of 3 pairs of parentheses (length 6) exist?

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

Correct answer: D. 5

The number of balanced sequences with n pairs is the Catalan number C_n, and C_3 = 5. Counting all ways to place 3 opening brackets among 6 positions (20) ignores balance.

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

Exams that ask this topic