im not getting any idea howto approach this problem…will someone help me please…??
Linked list k reversse
prajawal there are two ways
-
first reverse the link list upto a k and and make a node temp and send the head to the temp like
1 2 3 4 5 6 and k=2;
then send only 2 pair to reverse and then send the head in a temp node
like
if temp is NULL then temp=head else temp->next=head this will take o(k*n) time complexity -
the other way u can make a change in ur reverse function that it reverse k and then append the head of reverse ll to a temp node and then return that temp node
HOPE THIS HELP:)
If not understand then reply i will send u an pseudo code