Error
|
|
---|---|
@Ibrahim Nash | 6379 |
@blackshadows | 6329 |
@mb1973 | 5376 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@184025 | 108 |
@terabaap123 | 95 |
@arshjit_singh7 | 92 |
@anamikaprasad124 | 92 |
@kumsachin10 | 90 |
@vaibhavinayak | 75 |
@TanmayJ | 74 |
@NullPointerException | 74 |
@ronaldo77 | 72 |
@ritiksethi21 | 68 |
@bhupindersingh25122001 | 68 |
Complete Leaderboard |
Given two integers n and r, find nCr. Since the answer may be very large, calculate the answer modulo 109+7.
Example 1:
Input: n = 3, r = 2
Output: 3
Explaination: 3C2 = 3.
Example 2:
Input: n = 2, r = 4 Output: 0 Explaination: r is greater than n.
Your Task:
You do not need to take input or print anything. Your task is to complete the function nCr() which takes n and r as input parameters and returns nCr modulo 109+7..
Expected Time Complexity: O(n*r)
Expected Auxiliary Space: O(r)
Constraints:
1 ≤ n ≤ 1000
1 ≤ r ≤ 800
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes