Given a single linked list of size M, your task is to complete the function sumOfLastN_Nodes(), which should return the sum of last N nodes of the linked list.
The function takes two arguments as input, the reference pointer to the head of the linked list and the an integer N.
There will be T test cases and for each test case the function will be called seperately.
For each test case output the sum of last N nodes of the linked list.
5 9 6 3 4 10
Testcase 1: Sum of last three nodes in the linked list is 3 + 4 + 10 = 17.
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.