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
hide comments
Gaurav Dahima:
2016-09-17 19:10:31
top down TLE, bottom up AC !! |
|
rayhan50001:
2016-08-30 06:32:32
edit distance first problem solved.... Yesssss. |
|
madhavgaba:
2016-08-26 23:15:01
AC in one go:) |
|
iharsh234:
2016-08-20 11:28:22
challenge : do with dp[2][2005] ; ^_^ |
|
deerishi:
2016-08-02 19:33:53
Awesome Problem!! Good Dp practice. finally AC after quite a few WA's! |
|
ghost_wire:
2016-07-28 21:53:57
comments help a lot earlier i was getting runtime error ((SIGSEGV)).thanks @ranjanakash166.
|
|
isaac:
2016-06-26 23:46:50
@annu: It may be the fact the memory you allocate in the stack has overflowed.On the other hand, the global allocation has much more memory than stack at its disposal.However, all the parameters mentioned are configurable.
|
|
Annu Purohit:
2016-06-25 03:05:52
When the dp array is declared locally it gives run time error and when declared globally it awards you AC.Why? |
|
rishabh_1997:
2016-06-17 21:27:03
Got AC in the first attempt :) Very nice question. Declare global array of size 3000*3000 |
|
ranjanakash166:
2016-06-06 09:54:03
declare the dp[][] matrix table globally if one wishes to do it in BOTTOM-UP dp...otherwise most likely to get runtime error ((SIGSEGV)) |
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 |