Am Montag, 4. März 2013 07:52:11 UTC+1 schrieb nand kishore:
>
> I think DP soln would be :
>
> int leastPay(int[] demands, int sum, int index) {
>       if(index == demands.length)
>             return sum;
>       else {
>           if(sum < demands[index])
>                 return leastPay(demands, sum+demands[index], index+1);
>           else       
>               return Math.min(leastPay(demands, sum, index+1), 
> leastPay(demands, sum+demands[index], index+1));
>         }
>     }
>

Hi,
shouldn't this be: if(sum <= demands[index])?
Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to