@@ -0,0 +1,1767 @@
+//43. Multiply Strings%0A/**%0A * Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.%0A * %0A * Note:%0A * 1. The length of both num1 and num2 is %3C 110.%0A * 2. Both num1 and num2 contains only digits 0-9.%0A * 3. Both num1 and num2 does not contain any leading zero.%0A * 4. You must not use any built-in BigInteger library or convert the inputs to integer directly.%0A * %0A * Tags:  Math, String%0A * Show Similar Problems: (M) Add Two Numbers (E) Plus One (E) Add Binary (E) Add Strings%0A * %0A * @author Xinyue Zhang%0A *%0A */%0A%0Apublic class Solution %7B%0A    public String multiply(String num1, String num2) %7B%0A        if (num1.equals(%220%22) %7C%7C num2.equals(%220%22))%0A            return %220%22;%0A        //product length is smaller than the sum of two multipliers length%0A        int n1 = num1.length(), n2 = num2.length(), n = n1 + n2;%0A        int%5B%5D product = new int%5Bn%5D;%0A        //record the product of each digit%0A        for (int i = n1 - 1; i %3E= 0; i--)%0A            for (int j = n2 - 1; j %3E= 0; j--)%0A                product%5Bi + j + 1%5D += (num1.charAt(i) - '0') * (num2.charAt(j) - '0');%0A        //make each digit valid%0A        for (int i = n - 1; i %3E 0; i--) %7B%0A            product%5Bi - 1%5D += product%5Bi%5D / 10;%0A            product%5Bi%5D = product%5Bi%5D %25 10;%0A        %7D%0A        //convert product to string%0A        StringBuilder res = new StringBuilder();%0A        if (product%5B0%5D != 0)%0A            res.append(product%5B0%5D);%0A        for (int i = 1; i %3C n; i++)%0A            res.append(product%5Bi%5D);%0A        %0A        return res.toString();%0A    %7D%0A    %0A    public static void main(String%5B%5D args) %7B%0A        String num1 = %2213%22, num2 = %2212%22;%0A        Solution sol = new Solution();%0A        String res = sol.multiply(num1, num2);%0A        System.out.println(res);%0A    %7D%0A%7D%0A

Add Solution for 43. Multiply Strings