Multiply Linked Lists Problem Statement

Your task is to multiply two numbers represented as linked lists and return the resultant multiplied linked list.

Explanation:

The multiplied list should be a linked list representation of the product of the two numbers. Each node contains a single digit.

Input:

The first line contains an integer T, the number of test cases.
For each test case, the first line contains elements of the first linked list, separated by spaces and terminated by -1.
The second line contains elements of the second linked list, separated by spaces and terminated by -1.

Output:

For each test case, print the linked list representing the product, with elements single-space separated and terminated by -1.

Example:

Input:
2
3 4 2 -1
4 6 5 -1
5 6 -1
7 8 9 -1
Output:
1 5 8 1 0 -1
4 4 2 0 4 -1

Constraints:

  • 1 ≤ T ≤ 10
  • 1 ≤ N, M ≤ 100
  • 0 ≤ data ≤ 9 for any node in the list
  • Time Limit: 1 sec
Note:

You are not required to print anything; it has already been handled. Implement the function as instructed.

AnswerBot
4mo

Multiply two numbers represented as linked lists and return the resultant multiplied linked list.

  • Create a function that takes two linked lists as input and returns the product as a linked list

  • Traverse...read more

Help your peers!
Select
Add answer anonymously...

Scaleneworks Software Developer interview questions & answers

A Software Developer was asked Q. Right View of Binary Tree Given a binary tree of integers, your task is to outpu...read more
A Software Developer was asked Q. Buy and Sell Stock Problem Statement Imagine you are Harshad Mehta's friend, and...read more
A Software Developer was asked Q. Multiply Linked Lists Problem Statement Your task is to multiply two numbers rep...read more

Popular interview questions of Software Developer

A Software Developer was asked Q1. Right View of Binary Tree Given a binary tree of integers, your task is to outpu...read more
A Software Developer was asked Q2. Buy and Sell Stock Problem Statement Imagine you are Harshad Mehta's friend, and...read more
A Software Developer was asked Q3. Multiply Linked Lists Problem Statement Your task is to multiply two numbers rep...read more
Scaleneworks Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits