We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
if m==1 or n==1:
return 1
elif n==2 and m>1:
return m%c
else:
x=reduce(lambda x,y:pow(x*y,1,c), [pow(m+i,1,c) * pow(1+i,c-2,c) for i in range(n-1)])
return x
any idea why it is not fast enough? I know that it is O(n).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Matrix Tracing
You are viewing a single comment's thread. Return to all comments →
Hi,
I am trying the following in python:
any idea why it is not fast enough? I know that it is O(n).