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
2013-07-17 07:21:02 Jignesh
got AC when using scanf and WA with gets :(
2013-07-14 10:25:32 Ouditchya Sinha
Nice DP! :)
2013-07-06 11:04:23 i_am_what_i_am
give some test cases please!!
2013-07-04 18:51:03 chk
finally AC!
my 1st DP
2013-06-30 09:11:38 Himanshu
my third DP!!
my 150th submission.........:)
2013-05-15 17:51:39 ahmed ameen mohamed
1
ALLAHABAD
YATINDRA

9 Not 8
2013-05-14 19:21:58 ss
getting WA with c++ string and got AC with char array ... plz tell me reason
2013-03-15 12:06:02 iostream
@Yatindra , can u explain why is it 7 , mine is comming 8
2013-06-03 18:35:52 Rishi Poddar
Can the letter be inserted anywhere?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.