Javascript, dynamic programming, concise code with explanation
This is one of the problems taken directly from a farily well known algorithm.\n\nMinimum edit distance / Levenshtein Distance\nWhat are the minimal # of edits 
This is one of the problems taken directly from a farily well known algorithm.\n\nMinimum edit distance / Levenshtein Distance\nWhat are the minimal # of edits (change, add, delete char) to convert 1 string to another\nIt\'s a DP problem, looking at a character at a time.  \n\nFor each chacter, you either don\'t need to change it, you need to delete it, or you need to change it.\nKeep doing that character after character for each possibility and since we are interested in the minimum number of changes, just keep track of the lowest #.\n\nTake a look at this great visual explanation:\nhttps://www.youtube.com/watch?v=We3YDTzNXEk\n\n```\nvar minDistance = function(word1, word2) {\n  let dp = Array(word1.length+1).fill().map(()=>Array(word2.length+1)); // Get our DP matrix setup, no need for default values since we\'ll be filling each each of them\n  \n  for (let r=0; r<=word1.length; r++) {\n    for (let c=0; c<=word2.length; c++) {\n      if (r==0) dp[0][c] = c; // here we setup the initial row\n      else if (c==0) dp[r][0] = r; // here the initial column\n      else if (word1[r-1] == word2[c-1]) //now, if the letter is the same, cost is the same as the upper left cost\n        dp[r][c] = dp[r-1][c-1];\n      else //letters are different, so we will either need to change or delete one of the letters so prev cost +1 operation\n        dp[r][c] = Math.min(dp[r][c-1],dp[r-1][c-1], dp[r-1][c]) +1;\n    }\n  }\n  return dp[word1.length][word2.length]; //return the cost at the end of the string\n};\n```\n\nIf this explanation helped, please upvote this post so others can notice it.  Cheers!
['Dynamic Programming', 'JavaScript']