Leetcode POTD: Minimum ASCII Delete Sum of Two Strings

Leetcode POTD : Minimum ASCII Delete Sum of Two Strings Here, we need to delete minimum ASCII valued characters to make two strings equal. Intuition : 🤔 We want both strings to become the same, so we start with two pointers. If characters at both indices are equal → no deletion needed, just move ahead ✅ If characters are different, then we must delete, but the confusion is 🤯 👉 should we delete from s1 or from s2 to get the minimum cost? So we can try both options: delete from s1 delete from s2 This clearly points towards recursion 🔁 While solving recursively till the end of both strings, if you draw the recursion tree (yes, I did ✍️), you’ll notice overlapping subproblems. So why recompute? 🤷♂️ That’s where DP + memoization comes in We store results and optimize the solution efficiently. Attaching my thought process diagram below 👇 #Leetcode #POTD #DynamicProgramming #Recursion #DP #CodingJourney #programming

  • diagram, schematic

To view or add a comment, sign in

Explore content categories