<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 multiply(string num1, string num2) {

         // handle edge-case where the product is 0
        if (num1 == "0" || num2 == "0") return "0";
        
        // num1.size() + num2.size() == max no. of digits 
        vector<int> num(num1.size() + num2.size(), 0);
        
        // build the number by multiplying one digit at the time
        // Multiplication will occur just like the normal multiplication that learned do in the class 5th
        // Mulitplying last digit of first number with every digit of second number while maintaining the carry and going so on
        for (int i = num1.size() - 1; i >= 0; i--) {
            for (int j = num2.size() - 1; j >= 0; j--) {
                // For this solution let's say num[i+j+1] = digit 1 and num[i+j] = digit 2
                num[i + j + 1] += (num1[i] - '0') * (num2[j] - '0'); // Calculating digit 1
               // cout<<num[i+j+1]<<" ";  for the dry run check
                num[i + j] += num[i + j + 1] / 10;// Maintaining the carry of the digit 1
               //  cout<<num[i+j]<<" ";
                num[i + j + 1] %= 10; // digit 1 after giving up the carry to next digit 2
               // cout<<num[i+j+1]<<" ";
            }
        }
        
        // skip leading 0's in the number array 
        int i = 0;
        while (i < num.size() && num[i] == 0) i++;
        
        // transofrm the vector to a string 
        string res = "";
        while (i < num.size()) res.push_back(num[i++] + '0');
        
        return res;
    }
};
8363