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

    void mul(string s1, string s2,vector<vector<int>>&v){
        vector<int>v1;
        int len = s1.length(), mul =0 , c=0,r=0, len1 = s2.length();
        reverse(s1.begin(), s1.end());
        reverse(s2.begin(),s2.end());
        for(int j=0; j<len1; j++){
            mul =0 , c=0,r=0;
            v1.clear();
            int temp = j;
            while(temp){
                v1.push_back(0);
                temp--;
            }
        for(int i=0;i<len; i++){
            mul = int(s1[i]-'0') * int(s2[j]-'0');
            r = (mul+c)%10;
            c = (mul+c)/10;
            v1.push_back(r);
        }
        if(c!=0) v1.push_back(c);
        int vs = v1.size();
        while(vs < len1+len){
            v1.push_back(0);
            vs++;
        }
        v.push_back(v1);
        }
    }

    string multiply(string num1, string num2) {
       vector<vector<int>>v;
       vector<int>res;
       string s1 = num1, s2 = num2;
       int m1=0,m2=0;
       if(s1[0]=='-'){m1=1; s1 = s1.substr(1);}
       if(s2[0]=='-'){m2=1; s2 = s2.substr(1);}
       mul(s1,s2,v);

       int vs = v.size(),c=0;
       int len1=s1.length(), len2=s2.length();
      for(int i=0; i<len1+len2; i++){
          int sum=0;
          for(int j=0; j<vs; j++){
              sum = sum + v[j][i];
              
          }
          if(sum + c <10){ res.push_back(sum+c); c=0;}
          else{
                  res.push_back((sum+c)%10);
                  c=(sum+c)/10;
              }
          }
          if(c!=0) res.push_back(c);
      reverse(res.begin(), res.end());
      int ress = res.size();
      string rt = "";
      int flag=0;
      for(int i=0; i<ress; i++){
          if(flag==1) rt = rt + to_string(res[i]);
          if(flag==0 && res[i] > 0){
              rt = rt + to_string(res[i]);
              flag=1;}
              
      }
      if(rt.length()==0) return "0";
      if((m1==1 && m2==1) || (m1==0 && m2==0)) return rt;
      else  return ('-' + rt);
    }
};
16699