# Description

Given a singly linked list, determine if it is a palindrome.

The original problem is here.

The original code is here.

# My Solution

I solve this problem in C++, as below:

/*
*Author: shuaijiang
*Email: zhaoshuaijiang8@gmail.com
*/
#include<iostream>
#include<stdlib.h>
using namespace std;

/**
* Definition for singly-linked list.
* struct ListNode {
*     int val;
*     ListNode *next;
*     ListNode(int x) : val(x), next(NULL) {}
* };
*/

struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
bool isPalindrome(ListNode* head) {
return true;
ListNode *list1 = head;
ListNode *list2 = new ListNode(head->val);

list2->next = NULL;
list1 = list1->next;
while(list1 != NULL){
int num = list1->val;
ListNode *node = new ListNode(num);
node->next = list2;
list2 = node;
list1 = list1->next;
}
while(list1 != NULL && list2->next != NULL){
if(list1->val != list2->val)
return false;
list1 = list1->next;
list2 = list2->next;
}
return true;
}
};
//The code under below is used for test
int main(){
ListNode * head = new ListNode(1);
ListNode * node1 = new ListNode(2);
ListNode * node2 = new ListNode(0);