non Dynamic programming
Dynamic programming
Graph, flood fill by DFS