Solution to Edit Distance