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

//
// "19"
// "49"
//
//  81
//  90
// 360
// 400
//
//
//
class Solution {
public:
  string multiply(string num1, string num2) {
    vector<int> val ((num1.size() + 1) * (num2.size() + 1), 0);

    int currNum1Zeros = 0;

    for (int i = num1.length() - 1; i >= 0; i--) {
      int currNum1 = num1[i] - '0';
      int currNum2Zeros = 0;
      for (int j = num2.length() - 1; j >= 0; j--) {
        int currNum2 = num2[j] - '0';
        int currZeros = currNum1Zeros + currNum2Zeros;
        int num = currNum1 * currNum2;

        if (num > 9) {
          add(val, num / 10, currZeros + 1);
        }

        add(val, num % 10, currZeros);

        currNum2Zeros++;
      }

      currNum1Zeros++;
    }

    reverse(val);

    string ans = "";
    for (int i : val) {
      if (ans.length() == 0 && i == 0) {
        continue;
      }
      ans += i + '0';
    }

    if (ans == "") {
      return "0";
    }

    return ans;
  }

  void add(vector<int>& val, int num, int idx) {
    int curr = val[idx];

    curr += num;

    if (curr > 9) {
      add(val, 1, idx+1);
      curr -= 10;
    }

    val[idx] = curr;
  }

  void reverse(vector<int>& val) {
    int left = 0;
    int right = val.size() - 1;

    while (right > left) {
      swap(val[left], val[right]);
      left++;
      right--;
    }
  }

  void printNum(vector<int>& val, string message) {
    cout << message << endl;

    for (int k = val.size() - 1; k >= 0; k--) {
      cout << val[k];
    }
    cout << endl;
  }
};
10215