Skip to main content
๐Ÿ“œ WAYPOINT LESSON

Checkpoint โ€” Catalan Counts

โญ beginnerโณ 40 min read๐Ÿ“ Lesson 176 of 281

Bracket counts graded from n = 1 to n = 500000; a wrong answer that reports the central binomial instead of Catalan is the graded failure.

Checkpoint โ€” Catalan. Line 1: q. Each line: n. Print the number of balanced sequences of n bracket pairs mod 1e9+7.

C_n = C(2n, n) - C(2n, n + 1) with factorial tables.