/*
problem link: https://practice.geeksforgeeks.org/problems/reverse-a-linked-list/1/?page=1&difficulty[]=0&status[]=unsolved&sortBy=submissions#
*/
///////////////////////////////////////////////////////////////////////////////////////////
class Solution
{
public:
//Function to reverse a linked list.
struct Node* reverseList(struct Node *head)
{
// code here
// return head of reversed list
Node *p, *c, *n;
p=NULL;
c=head;
while(c!=NULL)
{
n=c->next;
c->next=p;
p=c;
c=n;
}
head=p;
return head;
}
};