Solved DP version of Edit Distances