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
|
||||||||||||||
2017-02-15 12:34:48
I don't understand. Does insertion and deletion take place only at the end or wherever in between? |
||||||||||||||
2017-01-30 21:09:50 Fodor Gabor
Python (both 2.7 and 3.4) seems to bump into TLE, both for the O(N*2) and O(N) memory versions. There's no point in even trying it. There seems to be 6 successful Python 2.7 submissions from 2015, but maybe they tightened the running time restriction since then. =(Francky)=> Please use PYPY here ; it will be easier to get AC. Time limit didn't change imho. Last edit: 2017-01-31 08:05:31 |
||||||||||||||
2017-01-23 08:16:08
Top down solution gets TLE?? |
||||||||||||||
2017-01-20 20:21:09
Awesome qs, done it in O(n*n) space complexity, can anybody please suggest a place where i can learn it solve it in O(n) space complexity? |
||||||||||||||
2017-01-06 09:18:05
beautiful question :) |
||||||||||||||
2016-12-02 15:17:31 Wumbolo
Resource is Internet? Really? |
||||||||||||||
2016-11-16 22:12:22
Well. That was an exercise in humility. |
||||||||||||||
2016-10-15 12:04:19
Find optimal substructure .Rest of the things are easy. |
||||||||||||||
2016-10-08 21:52:16 Robin Chawla
ac in one go :-) try MBLAST after that.. |
||||||||||||||
2016-10-06 21:05:14
getting TLE with python and AC with c++ ;f**k cost 2 WA |