I have used the nCr formulae to solve this in O(n).
the formulae is …nCr=nCr-1*((n-r+1)/r)
Using nCr property of pascal's triangle
do_it
#2
I tried using nCr formula but my code showed memory full and a segmentation fault occurred.
Please help.