P23 · 1 second · 256 MB
Binomial Coefficient
Return `C(n, k) mod 1_000_000_007`. `C(n, k)` is 0 when `k < 0` or `k > n`. `C(0, 0)` is 1. `n` and `k` are integers.
function nCrMod(n, k) → number
CONSTRAINTS
- 0 ≤ n ≤ 1000
- -10 ≤ k ≤ 1000
Input: n = 5, k = 2
Output: 10
Input: n = 10, k = 3
Output: 120
Input: n = 6, k = 7
Output: 0
1
2
3
4
5
6
7
8
Arena judges JavaScript in a Web Worker (1s wall-clock, then TLE). Samples are public; submit runs hidden tests too. C++/Python is a later swarm package.