Loading...
Loading...
Loading...
A bank needs to multiply account balances that have up to 200 digits, far too big for long. Read two non-negative whole numbers as text and print their product, without using BigInteger and without leading zeros.
Example 1
Input
123 456
Output
56088
Example 2
Input
99 99
Output
9801
Try the problem first. Open one hint at a time.
Do school multiplication. A product of an m-digit and an n-digit number has at most m + n digits, so use an int[m + n].
Digit i of the first number (from the left) times digit j of the second adds to position i + j + 1 of the array.
After all products, go from right to left and carry: keep % 10 and move / 10 to the left. Skip leading zeros when printing.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor