[algogeeks] Re: Amazon interview Question (Array yet again!)

2010-09-05 Thread Discover
ya exactly..dp solution is working... On Sep 5, 7:28 am, Gene gene.ress...@gmail.com wrote: I just figured out you are running the first (incorrect) greedy algorithm I tried.  Please try the DP.  It works fine. On Sep 3, 2:18 pm, Discover maniksinghal.n...@gmail.com wrote: @gene: nice

[algogeeks] Re: Simple reVerse

2010-09-04 Thread Discover
@shravan : but strrev() is using a while loop... On Sep 4, 12:26 pm, Shravan shravann1...@gmail.com wrote: int reverse(int x) {     char a[20];     int r;     sprintf(a,%d,x);     strrev(a);     r=atoi(a);     return r; } On Sep 4, 12:01 am, albert theboss alberttheb...@gmail.com

[algogeeks] Re: Amazon interview Question (Array yet again!)

2010-09-03 Thread Discover
@gene: nice solution.. but it's not working for a[]={20,22,13,11}; ur code will give soln : 24 but ans should be: 22 {11,11,11,11} pls correct me if i m wrong On Aug 28, 8:26 am, jagadish jagadish1...@gmail.com wrote: @Gene: Thanks alot! :-) your solution works like charm! On Aug 28, 7:09 

[algogeeks] Re: Amazon interview Question (Array yet again!)

2010-09-03 Thread Discover
nice explanation gene :) On Sep 2, 8:35 am, Gene gene.ress...@gmail.com wrote: Okay.  First, you can make the DP more efficient than the one I gave earlier. You don't need to scan the whole previous column when calculating costs of decrementing.  Rather there are only two possibilities. I