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

hide comments
Jignesh: 2013-07-17 07:21:02

got AC when using scanf and WA with gets :(

Ouditchya Sinha: 2013-07-14 10:25:32

Nice DP! :)

i_am_what_i_am: 2013-07-06 11:04:23

give some test cases please!!

chk: 2013-07-04 18:51:03

finally AC!
my 1st DP

Himanshu: 2013-06-30 09:11:38

my third DP!!
my 150th submission.........:)

ahmed ameen mohamed : 2013-05-15 17:51:39

1
ALLAHABAD
YATINDRA

9 Not 8

ss: 2013-05-14 19:21:58

getting WA with c++ string and got AC with char array ... plz tell me reason

iostream: 2013-03-15 12:06:02

@Yatindra , can u explain why is it 7 , mine is comming 8

Rishi Poddar: 2013-06-03 18:35:52

Can the letter be inserted anywhere?


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