Distance between 2 words using Dynamic Programming