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
2015-06-15 20:33:14 Manish Sombansh
Use global array and string array size of 3000. A size of 2000 is giving runtime error in C.
2015-06-14 19:23:18 Rishabh Joshi
Top down with memo gave TLE. (maybe im not using memo correctly)
Bottom up AC.
2015-06-02 19:49:17 SRC
Need some test cases ! Please help !
2015-05-31 10:45:03 :.Mohib.:
Finally done...:) First Dp... ;)
2015-05-29 00:15:22
use global variables and dynamic matrix got AC :p
2015-05-20 05:28:01 NEXES
dp or else TLE!!!!!
2015-05-18 14:13:58
can letters be inserted only at the end, or at the beginning and the end or anywhere in the word?
similar doubt for deletion
2015-05-18 06:39:24 siddharth rajan
Those who all are getting SIGSEGV error try to define the variables globally that might help!!!
2015-05-17 12:49:22 Varun Kumar
no need of an array of length 3000...the constraints in the problem are correct
2015-04-28 16:53:58
WA :) Can someone provide me some test cases please !!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.