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.
official_Hemant
4mo
class solution { public: long long multiplyTwoLists(Node *first, Node *second) { const long long mod = 1000000007; // 1e9 + 7 long long n1 = 0; long long n2 = 0; Node* temp1 = first; Node* temp2 = sec...read more
Help your peers!
Add answer anonymously...
Top Josh Technology Group Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
>
Josh Technology Group Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app