<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 f(string a,string b)
    {
        if(a.size()<b.size())swap(a,b);
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        while(b.size()<a.size())
        {
            b+='0';
        }
        int c=0;
        string ans="";
        for(int i=0;i<a.size();i++)
        {
            int s=(a[i]-'0')+(b[i]-'0')+c;
            ans+=((s%10)+'0');
            c=s/10;
        }
        if(c)
        {
            ans+=((c%10)+'0');  
        }
        reverse(ans.begin(),ans.end());
        return ans;
    }
    string multiply(string a, string b) {
        string ans="0";
        string z="";
        if(a=="0" || b=="0")return ans; 
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        for(int i=0;i<a.size();i++)
        {
            int c=0;
            string prev="";
            for(int j=0;j<b.size();j++)
            {
                int x=(a[i]-'0');
                int y=(b[j]-'0');
                int z=(x*y)+c;
                char ch=((z%10)+'0');
                prev=ch+prev;
                c=z/10;
            }
            if(c)
            {
                int z=c;
                 char ch=((z%10)+'0');
                prev=ch+prev;
                c=z/10;
            }
            cout<<prev<<endl;
            prev+=z;
            ans=f(ans,prev);
            z+='0';
        }
        return ans;
    }
};
30901