<p>Given two strings <code>s1</code> and&nbsp;<code>s2</code>, return <em>the lowest <strong>ASCII</strong> sum of deleted characters to make two strings equal</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s1 = &quot;sea&quot;, s2 = &quot;eat&quot;
<strong>Output:</strong> 231
<strong>Explanation:</strong> Deleting &quot;s&quot; from &quot;sea&quot; adds the ASCII value of &quot;s&quot; (115) to the sum.
Deleting &quot;t&quot; from &quot;eat&quot; adds 116 to the sum.
At the end, both strings are equal, and 115 + 116 = 231 is the minimum sum possible to achieve this.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s1 = &quot;delete&quot;, s2 = &quot;leet&quot;
<strong>Output:</strong> 403
<strong>Explanation:</strong> Deleting &quot;dee&quot; from &quot;delete&quot; to turn the string into &quot;let&quot;,
adds 100[d] + 101[e] + 101[e] to the sum.
Deleting &quot;e&quot; from &quot;leet&quot; adds 101[e] to the sum.
At the end, both strings are equal to &quot;let&quot;, and the answer is 100+101+101+101 = 403.
If instead we turned both strings into &quot;lee&quot; or &quot;eet&quot;, we would get answers of 433 or 417, which are higher.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s1.length, s2.length &lt;= 1000</code></li>
	<li><code>s1</code> and <code>s2</code> consist of lowercase English letters.</li>
</ul>

// Helper function to print pairs
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}

// Helper function to print containers like vector, set, etc.
template <typename Container>
void printContainer(const Container &container)
{
    std::cout << "{ ";
    for (const auto &element : container)
    {
        std::cout << element << " ";
    }
    std::cout << "}";
}

// Specialization for priority_queue (printing in sorted order)
template <typename T>
void printPriorityQueue(T pq)
{
    std::vector<typename T::value_type> elements;
    while (!pq.empty())
    {
        elements.push_back(pq.top());
        pq.pop();
    }
    std::reverse(elements.begin(), elements.end());
    printContainer(elements);
}

// dbg macro for single variables
#define dbg(var) std::cout << #var << " : " << var << std::endl

// Overload dbg for vector
#define dbg_vec(vec)            \
    std::cout << #vec << " : "; \
    printContainer(vec);        \
    std::cout << std::endl

// Overload dbg for set
#define dbg_set(s)            \
    std::cout << #s << " : "; \
    printContainer(s);        \
    std::cout << std::endl

// Overload dbg for map
#define dbg_map(m)                                        \
    std::cout << #m << " : { ";                           \
    for (const auto &[key, value] : m)                    \
    {                                                     \
        std::cout << "(" << key << ", " << value << ") "; \
    }                                                     \
    std::cout << "}" << std::endl

// Overload dbg for priority_queue
#define dbg_pq(pq)             \
    std::cout << #pq << " : "; \
    printPriorityQueue(pq);    \
    std::cout << std::endl

class Solution {
public:
    int dp[1001][1001];
    int asci(char ch){
      return  static_cast<int>(ch);
    }
    int helper(string &s1,string &s2,int i1,int i2){
      if(i1>=s1.size()){
        int cnt = 0;
        while(i2<s2.size()){
          cnt+= asci(s2[i2++]);

        }
        return cnt;
      }
      if(i2>=s2.size()){
        int cnt = 0;
        while(i1<s1.size()){
          cnt+= asci(s1[i1++]);

        }
        return cnt;

      }
      if(dp[i1][i2]!=-1)return dp[i1][i2];
      int take = INT_MAX;
      int nottake = INT_MAX;
      //take
      if(s1[i1]==s2[i2]){
        take = min(take,helper(s1,s2 ,i1 + 1,i2 + 1));
      }
      nottake = min({nottake,asci(s1[i1]) + helper(s1,s2,i1+1,i2),asci(s2[i2]) + helper(s1,s2,i1,i2 + 1)});
  
      // dbg(nottake);
      // dbg(take);
      return dp[i1][i2] = min(take,nottake);
    }
    int minimumDeleteSum(string s1, string s2) {
      memset(dp,-1,sizeof dp);
        return helper(s1,s2,0,0);
    }
};
13700