Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.

Note:&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.

&nbsp;
Example 1:
Input: num1 = "2", num2 = "3"
Output: "6"
Example 2:
Input: num1 = "123", num2 = "456"
Output: "56088"

&nbsp;
Constraints:


	1 &lt;= num1.length, num2.length &lt;= 200
	num1 and num2 consist of digits only.
	Both num1 and num2&nbsp;do not contain any leading zero, except the number 0 itself.


class Solution:
    def multiply(self, num1: str, num2: str) -> str:
        def convertToInt(numStr):
            currNum = 0
            N = len(numStr)
            for i in range(N - 1, -1, -1):
                digit = ord(numStr[i]) - ord('0')
                currNum += pow(10, N-i-1) * digit
                
            return currNum
        
        n1 = convertToInt(num1)
        n2 = convertToInt(num2)
        return str(n1 * n2)
      
class Solution {
    public String multiply(String num1, String num2) {
        if(num1.equals("0") || num2.equals("0"))
            return "0";
        int[] arr=new int[num1.length()+num2.length()];

        int index=0;
        for(int i=num1.length()-1;i>=0;i--)
        {
            int carry=0;
            int column=0;
            for(int j=num2.length()-1;j>=0;j--)
            {
                int a=(num1.charAt(i)-'0')*(num2.charAt(j)-'0');
                int temp=(arr[index+column]+carry+a);
                arr[index+column]=temp%10;
                carry=temp/10;
                column++;
            }
            if(carry!=0)
            {
                arr[index+column]=carry;
            }
            index++;
        }
        String ans="";
        index=arr.length-1;
        while(arr[index]==0)
        {
            index--;
        }
        for(int i=index;i>=0;i--)
        {
            ans+=arr[i];
        }
        return ans;
    }
}
class Solution {
    void compute(string &num, int dig, int ind, string &ans){
        int c = 0;  // carry digit..
        int i = num.size()-1;
        //  again travarsing the string in reverse
        while(i >= 0){
            int mul = dig*(num[i]-'0') + c;  // the curr digit's multiplication
            c = mul/10; // carry update..
            mul %= 10;  // mul update in  a single digit..
            if(ind >= ans.length()){    // here if the index where we'll put the value is out of bounds...
                ans.push_back('0' + mul);
            }
            else{
                //  here adding the val with the previous digit and further computing the carry...
                mul += (ans[ind] - '0');
                c += mul/10;
                mul %= 10;
                ans[ind] = ('0' + mul);
            }
            i--;
            ind++;  // increment the index where we'll put the val;
        }
        
        if(c > 0){ //   if carry is non-zero...
            ans.push_back('0' + c);
        }
        
    } 
public:
    string multiply(string num1, string num2) {
        string ans = "";    //  the string which we have to return as answer..
        if(num1 == "0" || num2 == "0") return "0";  // base case..
        int ind = 0;    // the index from which we'll add the multiplied value to the ans string
        for(int i  = num1.size()-1; i >= 0; ind++,i--){     
        // travarsing in reverse dir. on num1 and increasing ind bcz for every digit
        //  of num1 we'll add the multiplication in a index greater than the previous iteration
            int dig = num1[i]-'0';  // the digit with which we'll multiply by num2..
            compute(num2, dig, ind, ans);   // function call for every digit and num2
        }
//   we have calculated the ans in a reverse way such that we can easily add a leading digit & now reversing it...
        reverse(ans.begin(), ans.end());    
        return ans;
    }
};
var multiply = function(num1, num2) {
    const m = num1.length;
    const n = num2.length;

    const steps = [];
    let carry = 0;
    for(let i = m - 1; i >= 0; i -= 1) {
        const digitOne = parseInt(num1[i]);
        let step = "0".repeat(m - 1 - i);

        carry = 0;
        for(let j = n - 1; j >= 0; j -= 1) {
            const digitTwo = parseInt(num2[j]);

            const product = digitOne * digitTwo + carry;
            const newDigit = product % 10;
            carry = Math.floor(product / 10);

            step = newDigit + step;
        }

        if(carry > 0) step = carry + step;
        steps.push(step);
    }

    for(let i = 0; i < steps.length - 1; i += 1) {
        let nextStep = steps[i + 1];
        let step = steps[i];
        step = "0".repeat(nextStep.length - step.length) + step;

        carry = 0;
        let newStep = "";
        for(let j = step.length - 1; j >= 0; j -= 1) {
            const sum = parseInt(nextStep[j]) + parseInt(step[j]) + carry;
            const digit = sum % 10;
            carry = Math.floor(sum / 10);
            newStep = digit + newStep;
        }

        if(carry > 0) newStep = carry + newStep;
        steps[i + 1] = newStep;
    }

    let result = steps[steps.length - 1];
    let leadingZeros = 0
    while(leadingZeros < result.length - 1 && result[leadingZeros] === '0') {
        leadingZeros += 1;
    }

    return result.slice(leadingZeros);
};
Multiply Strings