Please enter your email address or userHandle.
Given two integers n and r, find nCr. Since the answer may be very large, calculate the answer modulo 109+7.
Input: n = 3, r = 2
Explaination: 3C2 = 3.
Input: n = 2, r = 4
Explaination: r is greater than n.
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)
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?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.