Multiply Strings Leetcode 43 question Correct Solution
Question : Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2 , also described as a string. Note: You must not use any built-in BigInteger library or directly convert the inputs to integers. Constraints: 1 <= num1.length, num2.length <= 200 num1 and num2 consist of digits only. Both num1 and num2 do not contain any leading zero, except the number 0 itself. /** * @param {string} num1 * @param {string} num2 * @return {string} */ var add = function ( a , b ){ // length of a should be smaller if ( a . length > b . length ) return add ( b , a ); // iterate a let i = a . length - 1 , j = b . length - 1 , carry = 0 , currAns = '' ; while ( i >= 0 ){ // get nums ...