EDIST - Edit distance

You are given two strings, A and B. Answer, what is the smallest number of operations you need to
transform A to B?

Operations are:

  1. Delete one letter from one of strings
  2. Insert one letter into one of strings
  3. Replace one of letters from one of strings with another letter

Input

T - number of test cases

For each test case:

  • String A
  • String B

Both strings will contain only uppercase characters and they won't be longer than 2000 characters. 

There will be 10 test cases in data set.

Output

For each test case, one line, minimum number of operations.

Example

Input:
1
FOOD
MONEY

Output:
4

Added by:Mislav Balunović
Date:2010-02-28
Time limit:15s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 SQLITE VB.NET
Resource:Internet

hide comments
2010-10-24 02:39:43 anonymous
@Tornike i dont think so ,because operation doesnt involve exchange of letters
2010-10-18 11:21:59 Himanshu
r u sure that Both strings will contain won't be longer than 2000 characters.
bcoz my programme get uploaded when i increase the size of array.
2010-10-12 17:39:11 cegprakash
@Tornike: i've the same doubt as u
2010-07-07 16:37:28 Tornike Mandzulashvili
what means "you need to transform A to B" ,is "bkoo" transformed to "book"?

Last edit: 2010-07-08 12:44:40
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.