119: Delete operation for two strings

Given two strings word1 and word2, return the minimum number of deletion required to make word1 and word2 the same. A deletion is allowed in either string

 

Example 1

Input:   word1 = "abc" word2 = "abc"

Output:  0

Example 2

Input:   word1 = "cab" word2 = "abc"

Output:  2

Explanation: remove c from cab and from abc

Difficulty:Medium
Topic:Dynamic programming
Problem #:119