add the solution of edit distance problem in leetcode and refactor code