We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
According to the problem statement...
1.)You need to figure out a way if head=NULL i.e if the list is empty but when you declare "if(head->next==NULL)" it means that you are consider only the non empty case.
2.)Even in this above case you are just returning "newn" nut you need to return thr address of first node which is "head"!
try adding
if(head==NULL) block of statements also
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a Node at the Tail of a Linked List
You are viewing a single comment's thread. Return to all comments →
According to the problem statement... 1.)You need to figure out a way if head=NULL i.e if the list is empty but when you declare "if(head->next==NULL)" it means that you are consider only the non empty case. 2.)Even in this above case you are just returning "newn" nut you need to return thr address of first node which is "head"!
try adding if(head==NULL) block of statements also