Don't understand when to take (head != NULL) or (head->next != NULL)

pls explain meaning of head!=NULL and head->next!=NULL
and the difference.

Run-error in 3 test cases

LINKED LIST-K APPEND Append the last K elements of a linked list to the front.K can be greater than N.

Hi @divyamsaxena123
use k%=n
only call kappend() if k>0
else print original list.

diff btw head!=NULL and head->next !=NULL
assuming in context of finding last element
while iterating in list, using while(head!=NULL), we stop at Null element after last element.
using while(head->next!=NULL), we stop at last element.

Hope it helps :slight_smile: