HI Rohit, Although i haven't checked test many cases also I am not saying algo is wrong but DP will always Gives us Optimal Solution, even for large data-set,but Greedy Will Fail in That Case.I was aware of the same Greedy Algo/Code That you posted but found DP Will Excite Interviewer :)
Regards >>> Shashank Mani "Computer Science Is Awesome So Why I Write Code" >>> Computer Science >>> Birla institute of Technology Mesra On Sat, Aug 13, 2011 at 11:08 PM, rohit jangid <rohit.nsi...@gmail.com>wrote: > ok check this, https://ideone.com/hZboG > there may be bugs in coding, but I'm quite sure that algo is correct > need to check more cases though > but working on all the cases discussed here > is there any proof that greedy won't work in this case? > > On Sat, Aug 13, 2011 at 11:03 PM, rohit jangid <rohit.nsi...@gmail.com> > wrote: > > found some bugs , will repost it > > > > > > On Sat, Aug 13, 2011 at 10:55 PM, rohit jangid <rohit.nsi...@gmail.com> > wrote: > >> I can only say that above code is wrong, check this code of mine, I > >> have tested more cases and all are working, > >> https://ideone.com/pEBs8 > >> see if you can find any bug in this one . > >> > >> thanks. > >> > >> On Sat, Aug 13, 2011 at 8:03 PM, WgpShashank < > shashank7andr...@gmail.com> wrote: > >>> @rohit , I think we will get some cases where greedy won't work check > out > >>> its giving 3 jumps still > >>> > >>> https://ideone.com/6UWW1 > >>> > >>> checked in hurray , if anything wrong do send me over gmail ? > >>> > >>> Regards > >>> Shashank Mani "Computer Science Is Awesome So Why I Write Code" > >>> Computer Science > >>> Birla institute of Technology Mesra > >>> > >>> -- > >>> You received this message because you are subscribed to the Google > Groups > >>> "Algorithm Geeks" group. > >>> To view this discussion on the web visit > >>> https://groups.google.com/d/msg/algogeeks/-/Rerf5mzR7XcJ. > >>> To post to this group, send email to algogeeks@googlegroups.com. > >>> To unsubscribe from this group, send email to > >>> algogeeks+unsubscr...@googlegroups.com. > >>> For more options, visit this group at > >>> http://groups.google.com/group/algogeeks?hl=en. > >>> > >> > >> > >> > >> -- > >> Rohit Jangid > >> Under Graduate Student, > >> Deptt. of Computer Engineering > >> NSIT, Delhi University, India > >> > > > > > > > > -- > > Rohit Jangid > > Under Graduate Student, > > Deptt. of Computer Engineering > > NSIT, Delhi University, India > > > > > > -- > Rohit Jangid > Under Graduate Student, > Deptt. of Computer Engineering > NSIT, Delhi University, India > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.