// calculate nCr in O(r) timelonglongbinCoef(intn,intr){r=min(r,n-r);intans=1;for(inti=0;i<r;i++){ans*=(n-i);ans/=i+1;}returnans;}// calculate the sum// sum will be 2nCn// O(n) solutionlonglongeasyline(intn){returnbinCoef(2*n,n);}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
C++