<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p>

<p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> num1 = "2", num2 = "3"
<strong>Output:</strong> "6"
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> num1 = "123", num2 = "456"
<strong>Output:</strong> "56088"
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= num1.length, num2.length &lt;= 200</code></li>
	<li><code>num1</code> and <code>num2</code> consist of digits only.</li>
	<li>Both <code>num1</code> and <code>num2</code>&nbsp;do not contain any leading zero, except the number <code>0</code> itself.</li>
</ul>

class Solution {
public:
    string update_sum(string s1, string s2) {
        
        string t1 = s1.length()<= s2.length() ? s1:s2;
        string t2;
        if(t1 == s1)
        t2 = s2;
        else
        t2 = s1;
        int i= t1.length()-1,j = t2.length()-1;
        int carry=0;
        string temp="";
        // cout<<"t1 : "<<t1<<" t2 : "<<t2<<endl;
        while(i>=0 && j>=0)
        {
            int x1 = t1[i] - '0', x2 = t2[j] - '0';
            int sum = x1 + x2 + carry;
            carry = sum/10;
            temp.insert(0,to_string(sum%10));
            i--;
            j--;
        }

        while(j>=0)
        {
            int sum = t2[j]-'0' + carry;
            carry = sum/10;
            temp.insert(0,to_string(sum%10));
            j--;
        }

        if(carry>0)
        temp.insert(0,to_string(carry));

        return temp;
    }
    string multiply(string num1, string num2) {
        if(num1=="0" || num2=="0")
        return "0";
        string s1 = num1.length() <= num2.length() ? num1 : num2;
        string s2;
        if (s1 == num1)
            s2 = num2;
        else
            s2 = num1;

        string store = "0";

        int i = s1.length() - 1;
        int p=0;

        cout<<"s1 : "<<s1<<endl;
        while (i >= 0) {
            int m = s1[i] - '0';

            int j = s2.length() - 1, carry = 0;
            string temp = "";
            while (j >= 0) {
                int x = s2[j] - '0';
                // cout<<"x : "<<x<<" m : "<<m<<endl;
                int value = x * m + carry;
                carry = value / 10;
                // cout<<"value : "<<value<<" carry : "<<carry<<endl;
                temp.insert(0, to_string(value%10));
                // cout<<"temp : "<<temp<<endl;
                j--;  
            }
            if (carry > 0)
                temp.insert(0, to_string(carry));
            // cout<<"temp : "<<temp<<endl;
            int z =p;
            while(z>0)
            {
                temp.push_back('0');
                z--;
            }
            store = update_sum(temp, store);
            // cout<<store<<endl;
            i--;
            p++;
        }

        return store;
    }
};
16081