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
Harish Reddy Kolanu: 2015-04-04 09:51:36

try using Wagner–Fischer algorithm
http://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm

Abhay Jain: 2015-03-21 12:52:32

Can somebody help. Its showing SIGSEGV error. Please help out.
Code link: http://ideone.com/********

(Francky) => Please use forum for any help. (See the notes below).

Last edit: 2015-03-21 14:12:29
Arjun Verma: 2015-03-17 18:10:03

2d array accepted with global + static int

gratitude: 2015-02-27 18:31:14

should use dp or else tle :)

Daniel Carvalho: 2015-02-17 16:36:23

Sigsev for 2D array and non-global variables. Works with 1D and global.

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

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