<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 add(const string &numStr1, const string &numStr2) {
    // Ensure numStr1 is the longer of the two strings
    string n1 = numStr1.size() >= numStr2.size() ? numStr1 : numStr2;
    string n2 = numStr1.size() < numStr2.size() ? numStr1 : numStr2;
    
    // Reverse the strings to make addition easier
    reverse(n1.begin(), n1.end());
    reverse(n2.begin(), n2.end());
    
    string result;
    int carry = 0;
    for (size_t i = 0; i < n1.size(); ++i) {
        int digit1 = n1[i] - '0';
        int digit2 = i < n2.size() ? n2[i] - '0' : 0;
        int sum = digit1 + digit2 + carry;
        result.push_back((sum % 10) + '0');
        carry = sum / 10;
    }
    
    if (carry) {
        result.push_back(carry + '0');
    }
    
    // Reverse the result string to get the final result
    reverse(result.begin(), result.end());
    
    return result;
}

    string multiply(string num1, string num2) {
        if(num1 == "0" || num2 == "0"){
            return "0";
        }
        int n = num1.length();
        int m = num2.length();
        string ans = "";
        for(int i = m - 1 ; i >= 0 ; i--){
            string temp = "";
            int carry = 0 , res = 0;
            for(int j = n - 1 ; j >= 0 ; j--){
                int mul = (num2[i] - '0')*(num1[j] - '0');
                res = mul + carry;
                carry = res/10;
                res %= 10;
                temp = (char)(res + '0') + temp;
            }
            if(carry != 0){
                temp = (char)(carry + '0') + temp;
            }
            for(int j = 0 ; j < (m - 1 - i) ; j++){
                temp += '0';
            }
            ans = add(ans , temp);
        }
        return ans;
    }
};
30593