hw is it possible frm this code ???????????/
Node * findNToLastNode( Node *head, int N )
{
int i = 0;
Node *current, *behind;
current = head;
for( i = 0; i < N; i++ ) {
if( current->next ) {
current = current->next;
} else {
return NULL; // Length of the list is less than N
}
}
behind = head;
while( current->next ) {
current = current->next;
behind = behind->next;
}
return behind;
}
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.