Advertisement
satishfrontenddev5

Untitled

Jan 21st, 2024
2,839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.
  3.  
  4. You have the following 3 operations permitted on a word:
  5.  
  6. Insert a character
  7.  
  8. Delete a character
  9.  
  10. Replace a character
  11.  
  12. Input format
  13. First line will have word1.
  14.  
  15. Second line will have word2.
  16.  
  17. Output format
  18. Minimum number of operations required to convert word1 to word2.
  19.  
  20. Constraints
  21. 1 <= |word1| <= 1000
  22.  
  23. 1 <= |word2| <= 1000
  24.  
  25. Sample Input 1
  26. horse
  27.  
  28. ros
  29.  
  30. Sample Output 1
  31. 3
  32.  
  33. Explanation 1
  34. horse -> rorse (replace 'h' with 'r')
  35.  
  36. rorse -> rose (remove 'r')
  37.  
  38. rose -> ros (remove 'e')
  39. */
  40.  
  41. /*
  42. TODO
  43. DP:33: striver
  44. https://www.youtube.com/watch?v=fJaKO8FbDdo&list=PLg0aancPZwRazLXPEW-vu517p3gXVCn0b&index=35
  45. */
  46. int editDistance(string str1, string str2)
  47. {
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement