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
hvar: 2016-05-27 07:39:05

2 tle just for array size make sure it is 2101*2101 and global happy coding :)

azam_9: 2016-05-23 07:58:00

my 1st dp..<3..AC after so many WA's..:D

bhushangawde: 2016-05-21 07:48:22

AC in 4th GO!! -_- SIGSEGV wen declared locally...when array declared globally it accepts....why not locally???

Last edit: 2016-05-21 07:48:43
lynx_: 2016-03-26 08:44:25

Declare Arrays of size 2001 in c ..costed me INFINIT :( WA ...for declaring 2000 size character .. :--(

ayush: 2016-03-21 22:07:34

Bottom-up AC in a go!!

Shivam Yadav: 2016-03-15 10:44:33

got AC using character array in top-down approach

ashish1032: 2016-03-07 01:55:40

Make the array global

gohanssj9: 2016-02-25 19:14:12

Levenshtein Distance :)

Akshay Raj: 2016-02-04 13:34:05

I'm getting TLE in bottomup dp..No idea what's wrong.

Aqib Ahmed J: 2016-01-27 17:22:55

AC in one go :) My 2nd DP problem :)


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