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
Siddharth Singh: 2015-12-17 13:22:49

My 2nd DP AC , After Many RE(SIGSEGV) , Feels Good <3
AC in one go in 0.16s C++14
Used Top Down Memo Without Global Declaration
set size of both strings =2101
and take 2d array dp[2101][2101] *BOTH As GLOBAL* to avoid RE

Last edit: 2015-12-17 15:40:31
Shubham Verma: 2015-12-15 20:29:32

In top down approach initialize 2d array of 2101*2101 to get AC else u will get RTE(SIGSEGV) .. :)

Junaid: 2015-12-15 12:14:47

My 2nd DP problem....took time to think...but finally AC in one go....;)

BALMUKUND SINHA: 2015-12-06 18:46:23

why declaring globally remove sigsegv error

bruzelee: 2015-12-01 14:44:11

use bottomup approach it will pass
topdown =tle

vedang: 2015-11-25 22:18:04

can anyone explain why does it give a SIGSEGV error on declaring the 2D array inside a function?

arjun: 2015-11-06 05:35:12

Declare all the variables as Global and the char array size must be >=2001.
Costed me 1 WA.
Watch this: https://www.youtube.com/watch?v=We3YDTzNXEk

dig: 2015-10-30 21:25:14

nice one...
top-down tle
bottom up ac

alok singh: 2015-09-30 13:13:41

no comment.... :P

gutsav: 2015-09-25 04:51:36

AC in one go 0.17 s :D


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