DataVisor interview question

dp problem, recursion, bfs/dfs problem