class Solution
{
public:
//Function to reverse a linked list.
struct Node* reverseList(struct Node *head)
{
if(head->next==NULL) return head;
Node *l,*t,*f;
l=head,t=head->next,f=head->next->next;
head->next=NULL;
while(t->next)
{
t->next=l;
l=t;
t=f;
f=f->next;
}
t->next=l;
head=t;
return head;
// code here
// return head of reversed list
}
};