in testcase number 5 there is run error,
plz check the code and revert the changes
Linked List-K Append
@akb.tech17 hey anshul in your code insert at tail calling in the wrong manner and your k append function is not right
follow this k append function for your problem and send data from main into insert at tail function.
node* append(node * head , int k,int n){
node * last;
last = head;
node * temp2=head;
int i=0;
k = k%n;
//if k is greater than n then - value
int ok = n-k-1;
if(k==0||k<0){
return head;
}
while(last != NULL && i<ok){
last = last -> next;
i++;
}
temp2 = last;
node*second = temp2->next;
node*third=second;
temp2->next=NULL;
while(second->next!=NULL){
second=second->next;
}
second->next=head;
last->next=NULL;
return third;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.