<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 multiply2(string s1, char s2, int dec)
    {
        cout << s1 << ":" << s2 << endl;
        int rem = 0, i=s1.length()-1;
        string ans;
        while(i>=0)
        {
            int temp = (s1[i] - 48) * (s2 - 48) + rem;
            ans.push_back((char)(temp % 10 + 48));
            rem = temp/10;
            i--;
        }
        if(rem != 0)
            ans.push_back(rem + 48);
        reverse(ans.begin(), ans.end());
        while(dec != 0)
        {
            ans.push_back(48);
            dec--;
        }
        return ans;
    }
    string sum(string num1, string num2)
    {
        string s1, s2;
        if(num1.length() > num2.length())
        {
            s1 = num1; 
            s2 = num2;
        }
        else
        {
            s1 = num2; 
            s2 = num1;
        }
        int i = s1.length()-1, j = s2.length() - 1, rem = 0;
        string ans;
        while (i >= 0)
        {
            int temp;
            if(j < 0)
            {
                temp = s1[i] -48 + rem;
                ans.push_back(temp % 10 + 48);
                rem = temp / 10;
            }
            else
            {
                temp = s1[i] + s2[j] + rem - 48*2;
                ans.push_back(temp % 10 + 48);
                rem = temp / 10;
            }
            i--;
            j--;
        }
        if(rem != 0)
            ans.push_back(rem + 48);
        reverse(ans.begin(), ans.end());
        return ans;
    }
    string multiply(string num1, string num2) {
        string s1, s2;
        if(num1 == "0" || num2 == "0")
            return "0";
        if(num1.length() > num2.length())
        {
            s1 = num1; 
            s2 = num2;
        }
        else
        {
            s1 = num2; 
            s2 = num1;
        }
        string ans = "0";
        int i = s1.length()-1, j = s2.length() - 1;
        int dec = 0;
        while(j >= 0)
        {
            string temp = multiply2(s1, s2[j], dec);
            cout << "temp:" << temp << endl;
            ans = sum(ans, temp);
            cout << "ans:" << ans << endl;
            dec++;
            j--;
        }
        return ans;
    }
};
16390