first and second. In one step you may erase exactly one letter from either word; the remaining letters close the gap and keep their order.
Return the smallest number of steps after which the two words are identical (two empty strings count as identical).first='stone', second='notes' → 6
The longest part both words can keep is one (or ote, and so on), three letters. Two letters go from each word, 4 in total.
first='abc', second='abc' → 0
The words are already equal.
first='mint', second='x' → 5
There are no common letters, so both words must be erased entirely: 4 + 1 = 5.
first='stone', second='notes'
6
Run checks the first 3 tests in your browser. Submit checks all 107 tests on the server, hidden ones included.