#include
using namespace std;
class LL{
public:
int data;
LL *next;
LL(int d)
{
data=d;
next=NULL;
}
};
void push(LL *&head,int data)
{
LL* temp = new LL(data);
temp->next = head;
head = temp;
}
void reversebyK(LL *&head,int K)
{
int jump=1;
LL *prev=NULL;
LL *current=head;
while(jump<=K-1)
{
prev=current;
current=current->next;
jump++;
}
head->next=current->next;
current->next=prev;
prev->next=head;
}
void print(LL *head)
{
while(head!=NULL)
{
cout<<head->data<<"->";
head=head->next;
}
}
int main() {
LL *head=NULL;
push(head,4);
push(head,5);
push(head,8);
push(head,9);
push(head,3);
push(head,1);
push(head,2);
reversebyK(head,3);
print(head);
}