Maybe you'll need to tighten up the problem to make it interesting. By your description you could just go all the way up and all the way down in each column and pick up all the apples and then make a move to the right and do the same thing in that column and so on until you get to the destination column. Enter that one at the top or bottom, whichever is farthest the goal, and then move to the goal. You'll get all the apples in all the columns between and including start and goal columns.
Maybe you mean you can go northeast, east, and southeast only? That way it's a DP. Or maybe you mean that you're not allowed to visit the same square twice? That would also be interesting (and harder)! On Dec 13, 11:44 am, Azhar Hussain <azhar...@gmail.com> wrote: > We have apples arranged in a mxn matrix. We start from the upper left > corner and have to reach bottom right corner with maximum apples. We can > only move either down or right. > Now if we can start any where in the matrix and have to reach anywhere on > the right(reach n column). We can either up, down, right(but not left). We > have to collect maximum apples from a given location. > I am trying to solve problem. solution for the first one is given > athttp://community.topcoder.com/tc?module=Static&d1=tutorials&d2=dynProg. > What data structure would be suitable for the second problem and will > dynamic programming work. > > Thanks in advance. > Azhar. -- 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.