Submit | All submissions | Best solutions | Back to list |
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:
- Delete one letter from one of strings
- Insert one letter into one of strings
- 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
|
||||||||||||||
2016-01-27 17:22:55 Aqib Ahmed J
AC in one go :) My 2nd DP problem :) |
||||||||||||||
2016-01-16 19:13:01 bharadwaj
Hi guys, I am getting a WA if I use it in C++ strings... If do it using the char array in C it is being accepted.... |
||||||||||||||
2016-01-07 08:06:03 Alex-ander007
Got AC for bottom-up. TLE for top-down. Why? Also why locally declared array is giving SIGSEGV? |
||||||||||||||
2015-12-24 11:15:52 Shantanu Banerjee
simple Wagner Algo! |
||||||||||||||
2015-12-17 13:22:49 Siddharth Singh
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 |
||||||||||||||
2015-12-15 20:29:32 Shubham Verma
In top down approach initialize 2d array of 2101*2101 to get AC else u will get RTE(SIGSEGV) .. :) |
||||||||||||||
2015-12-15 12:14:47 Junaid
My 2nd DP problem....took time to think...but finally AC in one go....;) |
||||||||||||||
2015-12-06 18:46:23 BALMUKUND SINHA
why declaring globally remove sigsegv error |
||||||||||||||
2015-12-01 14:44:11
use bottomup approach it will pass topdown =tle |
||||||||||||||
2015-11-25 22:18:04 vedang
can anyone explain why does it give a SIGSEGV error on declaring the 2D array inside a function? |