Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2 (Operations: Insert, Delete, Replace).
Input: word1 = "horse", word2 = "ros"
Output: 3
Explanation: horse -> rorse -> rose -> ros
Topics: dp
Asked by: Amazon, Google, Meta, Microsoft, Apple
Time complexity: O(m×n). Space complexity: O(n).