Suppose I have a NxN grid (or matrix) and each entry has integers. There is a standard DP problem where you want to find the maximum sum path from top left corner and bottom right corner, using only 'down' and 'right' moves, which can be solved in quadratic time. But I have a modified version of the problem, which states that I start from top left and reach bottom right, using 'down' and 'right' moves, and from there, I have to return back to top left again using 'up' and 'left' moves, and I want to find the maximum sum path. The restriction here is that you're allowed to visit entries that have already been visited by the first path you traversed from top left corner to bottom right corner, but you're not allowed to count that integer since you don't want to double count.
I want to solve this problem using DP though. I've been thinking about this for hours and couldn't come up with a solution. What would be a good way to start? The first thing I tried is find the maximum path from top left to bottom right corner, set all entries of the path to 0, rotate the grid, and do the same thing, and add those paths together, which clearly does not work. I'm having difficulty how to formulate subproblems. PLEASE PLEASE do not post any solutions here.