Which is better way to calculate nCr
Both approaches will save time, but the first one is very prone to integer overflow. Approach 1: This approach will generate result in shortest time (in at most n/2 iterations), and the possibility of overflow can be reduced by doing the multiplications carefully: long long C(int n, int r) { if(r > n – r) … Read more