1474. Delete N Nodes After M Nodes of a Linked List
Problem
Given a linked list, delete N nodes after every M nodes and return the modified list.
Given the head of a linked list and two integers m and n, delete n nodes after every m nodes in the list. This pattern continues until the end of the list.
The deletion is done in-place, meaning you modify the original list.
Examples
Input:[[1,2,3,4,5,6,7,8,9,10,11,12,13],2,3]
Output:[1,2,6,7,11,12]
Input:[[1,2,3,4,5,6,7,8,9,10,11],1,3]
Output:[1,5,9]
Hints
Use two pointers: one to track the node before the segment to keep, and one to traverse.
Skip m nodes, then delete n nodes, and repeat.
Be careful with edge cases when reaching the end of the list.