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.
I have read some codes but i still cant understand why my code return the different result. Did it reach the limit of the long type?
The results are either negative numbers or 0.
publicstaticintsolve(intn,intm){// Write your code herem--;if(n>m){inttemp=n;n=m;m=temp;}inti=m+1;longprod=1;while(i<=n+m){prod*=i++;}// return (int) prod;i=2;while(i<=n){prod/=i++;}return(int)(prod%1000000007);}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
I have read some codes but i still cant understand why my code return the different result. Did it reach the limit of the long type? The results are either negative numbers or 0.