You start at top-left cell of a given grid. Some cells have wall, some you can walk, and some cells have apple. You are given a time limit = T, and you should reach bottom right cell by atmost T time. Find maximum number of apples you can collect. You cannot visit a cell twice. N, M, T <= 14.
I tried a lot of ideas, most promising one is this - rephrase problem as find shortest time to reach destination collecting atleast X apples. Then we could binary search on number of apples. But I am not able to pin down a solution from last 6hours. "You cannot visit a cell twice." this is causing me problem.
Any other idea or hint is appreciated.