Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com

Multiply Strings

Moderate
0/80
Average time to solve is 35m
53 upvotes
Asked in companies
SnapdealGoogleFacebook

Problem statement

You are given two big numbers ‘A’ and ‘B’ as strings. Your task is to find the product of both the numbers.

Note:

There are no leading zeros in both the strings, except the number 0 itself.
Do not use any built-in Big Integer Library.
For Example:
If, A = 123, and B = 456.
So the product of both numbers will be 56088.
Detailed explanation ( Input/output format, Notes, Images )
Constraints:
1 <= T <= 100
1 <= |A|, |B| <= 100

where |A| and |B| denote the length of string, ‘A’ and ‘B’ respectively.   
All the characters of the string ‘A’ and ‘B’ contain digits only.

Time limit: 1 second
Sample Input 1:
2
17281 
91276
123
456
Sample Output 1:
1577340556
56088    
Explanation for sample 1:
For the first test case:
A=17281, and B=91276
The product of both numbers is 1577340556.

For the second test case:
A=123, B=456
The product of both numbers is 56088
Sample Input 2:
1
5
10
Sample output 2:
50
Full screen
Console