<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 addTwoStrings(string num1, string num2) {
        string n1 = num1.size() >= num2.size() ? num1 : num2;
        string n2 = num1.size() < num2.size() ? num1 : num2;

        reverse(n1.begin(), n1.end());
        reverse(n2.begin(), n2.end());

        while (n2.size() < n1.size()) {
            n2 += '0';
        }
        // return n1;

        string result = "";
        int carry = 0;

        for(int i = 0; i < n1.size(); ++i) {
            int sum = (n1[i] - '0') + (n2[i] - '0') + carry;
            carry = sum / 10;
            result += (sum % 10) + '0';
        }

        if (carry) {
            result += carry + '0';
        }

        reverse(result.begin(), result.end());

        return result;
    }
    string multiply(string num1, string num2) {

        if(num1 == "0" || num2 == "0")return "0";

        string s1,s2;
        if(num1.length() < num2.length()){
            s1 = num1;
            s2 = num2;
        }
        else {
            s1 = num2;
            s2 = num1;
        }
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
        
        int carry = 0;
        string ans = "0";
        for(int i = 0 ; i < s1.length(); i++){

            int by = s1[i] - '0';
            string res ="";

            for(int j = 0; j < s2.length(); j++){
                int to = s2[j] - '0';
                int pro = (to*by)+carry;

                carry = pro/10;
                pro = pro%10;

                char ch = pro + '0';
                res.push_back(ch);
            }
            if(carry != 0){
                char ch = carry + '0';
                res.push_back(ch);
                carry = 0;
            }
            reverse(res.begin(),res.end());
            res.append(i, '0');
            ans = addTwoStrings(res, ans);
        }
        return ans;
    }
};
17008