Practice · 1 of 3
Balanced Sequences
CHALLENGE
Difficulty: advanced+25 XP
**Problem.** Line 1: q. Each line: n. Print the number of balanced sequences of n pairs of brackets mod 1e9+7. **Constraints:** 1 ≤ q ≤ 500000; 1 ≤ n ≤ 500000. Factorial precompute + the Catalan identity; the O(n^2) recurrence W cannot finish.
Press Submit to check your solution.
Back to lesson: Practice: Counting Suite