Given two polynomials represented by two linkedlists that contains the coefficients of poynomials. Your task is to complete the method **proOfPolynomials()** which takes four arguments: the address of the head of the linked list1, the address of the head of the linked list2, size of linked list1 and size of linked list2. The function returns the head of a linked list formed after multiplication of given polynomials.

**Input:**

The first line contains an integer T, depicting total number of test cases. First line of each test case contains two integers M and N,highest degree of the polynomial linked list1 and linked list2. Next two line contains M and N integers , decribes the coefficients of polynomials.

**Output:**

Print the coefficients of resultant poynomial.

**User Task:**

The task is to complete the function **proOfPolynomials**() which should multiply the given polynomial.

**Constraints:**

1 <= T <= 100

1 <= M, N <= 100

1 <= size of list1 & list2 <= 100

**Example:**

**Input:**

2

4 3

1 0 3 2

2 0 4

5 4

1 9 3 4 7

4 0 2 5

**Output:**

2 0 10 4 12 8

4 36 14 39 79 23 34 35

**Explanation:**

**Testcase 1:**

First polynomial:

1 + 0x^1 + 3x^2 + 2x^3

Second polynomial:

2 + 0x^1 + 4x^2

Product polynomial:

2 + 0x^1 + 10x^2 + 4x^3 + 12x^4 + 8x^5

**Testcase 2:**

First polynomial:

1 + 9x^1 + 3x^2 + 4x^3 + 7x^4

Second polynomial:

4 + 0x^1 + 2x^2 + 5x^3

Product polynomial:

4 + 36x^1 + 14x^2 + 39x^3 + 79x^4 + 23x^5 + 34x^6 + 35x^7

Author: Amit Khandelwal 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

cs_abhi | 62 |

kya_bolti_public | 56 |

Shubhankar Sharma | 44 |

vermaankush14291 | 42 |

coderquill | 40 |

PiyushPandey4 | 856 |

john_wick | 757 |

ASWATHAMA | 565 |

akhyasharma01 | 547 |

UsfShilpa | 536 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.