CODE-
#include
using namespace std;
class node
{
public:
int data;
node* next;
node(int x)
{
data=x;
next=NULL;
}
};
class linklist
{
public:
node* head;
node* tail;
linklist()
{
head=NULL;
tail=NULL;
}
void Insertion(int x)
{
node* n=new node(x);
if(head==NULL)
{
head=n;
tail=n;
}
else
{
tail->next=n;
tail=n;
}
}
bool palindrome(node* head,node* temp)
{
while(temp->next!=NULL)
{
palindrome(head,temp->next);
}
while(head->data==temp->data)
{
head=head->next;
if(head->data!=tail->data)
{
return false;
}
}
return true;
}
};
int main()
{
linklist l;
int n;
cin>>n;
while(nā)
{
int x;
cin>>x;
l.Insertion(x);
}
node* temp=l.head;
cout<<boolalpha<<l.palindrome(l.head,temp);
return 0;
}
// i cant find where is the problem