can you please and explain about both code and logic?
LL - k Reverse problem with code
The approach you have used in your code is not correct for kreverse, basically you have to take 3 pointers of type node as
node *current=head;
node *prev=NULL;
node *next=NULL;
Initialise count as 0, and then apply the logic for reversing the linked list,uptil
while(current!=NULL && count<k)
{
//reverse code,
count++;
}
and then recursively call the function for other set of elements.
if(next!=NULL)
{
head->next=reverse(next,k);
}
Try using this approach in your code.