Easy · Binomial Recurrence
Understand → Visualise → Practice.
Return the zero-indexed row of Pascal's triangle.
Entry k of row n is C(n, k), and C(n, k) = C(n, k − 1) × (n − k + 1) / k. Each entry follows from the one before it.
C(n, 0) = 1.
For k = 1..n, append previous × (n − k + 1) // k; the division is always exact.
The row has n + 1 entries and is symmetric.
O(n) time and O(n) space for the output.
Dividing before multiplying loses precision; multiply first so the division stays exact.
Read the full guide first: Number Theory Basics for Algorithms.
Guest mode lets you understand, visualise and run the sample tests. Create a free account to submit and save your solutions.