Hướng dẫn deletion distance javascript
25 Apr 2018 Show OverviewThe deletion distance of two strings is the minimum number of characters you need to delete in the two strings in order to get the same string. For instance, the deletion distance between
Examples:
Constraints:
Hints
SolutionLet
This is true because if one string is the empty string, we have no choice but to delete all letters in the other string.
This holds since we need to delete at least one of the letters
This holds since we don’t need to delete the last letters in order to get the same string, we simply use the same deletions we would to the Solution 1After finding the relations above for Pseudocode:
Time Complexity: we have a nested loop that executes Space Complexity: we save every value of Solution 2The solution above takes Pseudocode:
Time Complexity: the time complexity stays the same, i.e. Space Complexity: Example CodePHP code
Python code 1 (working)
Python code 2 (not working)
Python code 3 (not working)
Test casePHP
Python
https://stackoverflow.com/questions/44490091/deletion-distance-between-2-strings https://stackoverflow.com/questions/41275345/deletion-distance-between-words |