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

Multiply Linked Lists

Easy
0/40
Average time to solve is 15m
profile
Contributed by
17 upvotes
Asked in companies
AmazonSamsungJosh Technology Group

Problem statement

Given two numbers represented by linked lists. Your task is to find the multiplied list and return the head of the multiplied list.

The multiplied list is a linked list representation of the multiplication of two numbers.

Detailed explanation ( Input/output format, Notes, Images )
Constraints :
1 <= T <= 10
1 <= N, M <= 100
0 <= data <= 9

Where N and M are the number of nodes in the two linked lists.

Time Limit: 1 sec
Sample Input 1:
1
5 6 3 -1
8 4 2 -1
Sample Output 1:
4 7 4 0 4 6 -1
Explanation of Sample Input 1:
563 * 842 = 474046
Sample Input 2:
2
7 5 9 4 6 -1
0 -1
0 2 3 4 0 - 1
0 0 1 -1
Sample Output 2:
0 -1
2 3 4 0 -1
Explanation of Sample Input 2:
75946 * 0 = 0
02340 * 001 = 2340  
Full screen
Console