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
Tejwinder Singh: 2015-02-16 17:17:04

I am frustated
http://ideone.com/**********
please help me out :(

(Francky) => Please use forum, and read notes.

Last edit: 2015-02-16 18:06:48
Andrey Kaygorodov: 2015-02-06 20:03:28

@shankar should be 4

shankar: 2015-02-04 19:31:21

what should be the answer for
1
qwert
ertqw

Answer should be 4 or 2 ?

Anubhav Gupta: 2015-02-04 01:32:40

Levenshtein distance

Abhay: 2015-01-23 13:08:24

Can someone provide me some sample test cases? The judge is giving me WA but I have been correct in all the examples I have tried.

Edit: Found the mistake

Last edit: 2015-01-23 13:21:32
Kaustubh Mallik: 2015-01-22 06:29:02

Even 2D array solution is accepted. :D

Takanori MAEHARA: 2015-01-18 16:59:55

@simple
My 0.02s solution is a bit-parallel algorithm. see http://www.sis.uta.fi/~hh56766/pubs/psc02.pdf

Infinity: 2014-10-18 08:39:53

my time 1.21
best time 0.1 and 0.5
I WOULD like to know your approach.

Last edit: 2014-10-18 08:40:46
mandu_ism: 2014-10-05 23:52:48

Made a mistake in calculating min!!

I need sleep :(

mayank: 2014-09-29 10:48:32

There is no need for 1D array, in C++ at least. :)


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