Amazon Interview Question

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