Timer is Running

Delete N nodes after M nodes of a linked list
Submissions: 23372   Accuracy:


  Difficulty: Easy   Marks: 2
Associated Course(s):   Interview Preparation

Given a linked list, delete N nodes after skipping M nodes of a linked list until the last of the linked list.

First line of input contains number of testcases T. For each testcase, first line of input contains number of elements in the linked list and next M and N respectively space separated. The last line contains the elements of the linked list.

Function should not print any output to stdin/console.

User Task:
The task is to complete the function linkdelete() which should modify the linked list as required.


2 1
9 1 3 5 9 4 10 1
6 1
1 2 3 4 5 6

9 1 5 9 10 1
1 2 3 4 5 6

Testcase 1
: Deleting one node after skipping the M nodes each time, we have list as 9-> 1-> 5-> 9-> 10-> 1.


** For More Input/Output Examples Use 'Expected Output' option **

Author: Jaspreet Singh

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.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.