element of the list. Code it.(Ex. when m=0 the last element of the LL is
returned).
Answer:
[2] -> [3] -> [4] -> [5] -> ..... [100]
^ ^
mThToLast last --->
|----------------------|
distance = m
Node *mThToLast = head;
Node* last = head;
while ( m )
{
last = last->next;
--m;
}
while( last->next )
{
mThToLast= mThToLast->next;
last = last->next;
}
No comments:
Post a Comment