DP is good when we need to use intermediate values too..
here we only need to compute nCr as a final result
so we cannot use DP here

the Logic Vandana used will be helpful here.

as nCr = n! / r! * n-r!
without loss of generality we can assume that r < n-r else we can just
replace r = n-r

 then we need to compute is
(n-r+1)*(n-r+2)*.........*(n) / 1.2.3.....r
that can be computed in O(r)


On Tue, Jun 21, 2011 at 2:04 PM, kartik sachan <[email protected]>wrote:

> but for big numbers this method is very expensive................and hope
> give TLE in 1 sec question where n=1000
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to