A
Aditya
This is a normal interview question, which goes like this
"Given a linked list of integers, delete every mth node and return the
last remaining node."
eg: Linked list = 4->6->7->3->5->6->10->1->23->17
Delete every 3rd node (m = 3) and return the last remaining node
meaning...
4->6->3->5->10->1->17
4->3->5->1->17
3->5->17
3->17
3
after deleting every 3rd node the last remaining node is 3, so node
with data 3 is returned.
function prototype:
node* deleteEveryMth(node** head, int m)
{
// .... your code
}
thanks
A
"Given a linked list of integers, delete every mth node and return the
last remaining node."
eg: Linked list = 4->6->7->3->5->6->10->1->23->17
Delete every 3rd node (m = 3) and return the last remaining node
meaning...
4->6->3->5->10->1->17
4->3->5->1->17
3->5->17
3->17
3
after deleting every 3rd node the last remaining node is 3, so node
with data 3 is returned.
function prototype:
node* deleteEveryMth(node** head, int m)
{
// .... your code
}
thanks
A