<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>

void reversestring(string &a){
    int left=0,right=a.size()-1;
        while(left<right){
            char t;
            t=a[left];
            a[left]=a[right];
            a[right]=t;
            left++;
            right--;
        }    
}
string addbignum(string a,string b){
    reversestring(a);
    reversestring(b);
    string result="";
    string cpy=a;
    if(a.size()<=b.size()){
        a=b;
        b=cpy;
    }
    while(b.size()<a.size()){
        b=b+'0';
    }
    int du=0;
    for(int i=0;i<b.size();i++){
        int x=a[i]-'0'+b[i]-'0'+du;
        result+=(x%10)+'0';
        du=x/10;
    }
    if(du!=0){
        result+=du+'0';
    }
    reversestring(result);
    return result;
}
string productstring(string a,char c){
    string ans="";
    int du=0;
    for(int i=a.size()-1;i>=0;i--){
        int product=(a[i]-'0')*(c-'0');
        product+=du;
        ans+=(product%10)+'0';
        du=product/10;
    }
    if(du!=0){
        ans+=du+'0';
    }
    reversestring(ans);
    return ans;
}
class Solution {
public:
    string multiply(string num1, string num2) {
        if(num1=="0"||num2=="0"){
            string ans="0";
            return ans;
        }
        vector<string>saved;
        int c=0;
        for(int i=num1.size()-1;i>=0;i--){
            string tmp=productstring(num2,num1[i]);
            for(int z=0;z<c;z++){
                tmp+='0';
            }
            saved.push_back(tmp);
            c++;
        }
        string ans="";
        for(int i=0;i<saved.size();i++){
            ans=addbignum(ans,saved[i]);
        }
        return ans;
    }
};
20095