Amazon interview question

just a DSA question leetcode medium level problem(edit distance)