# Leetcode Palindrome Linked List problem solution

In this Leetcode Palindrome Linked List problem solution we have given the head of a singly linked list, return true if it is a palindrome.

## Problem solution in Python.

```class Solution(object):
return True

nums = []
while curr:
nums.append(curr.val)
curr = curr.next

left = 0
right = len(nums) - 1

while left <= right:
if nums[left] != nums[right]:
return False
else:
left += 1
right -= 1

return True
```

## Problem solution in Java.

```class Solution {

Stack<Integer> stack = new Stack <Integer>();

while (curr != null) {
stack.push(curr.val);
curr = curr.next;
}

return false;
}
else {
}
}

return true;
}
}
```

## Problem solution in C++.

```class Solution {
public:
vector<int>tab;
ListNode* p;
while(p!=nullptr){
tab.push_back(p->val);
p=p->next;
}
int n=tab.size();
for(int i=0;i<n/2;i++){
if(tab[i]!=tab[n-i-1])return false;
}
return true;
}
};
```

## Problem solution in C.

```bool isPalindrome(struct ListNode* head){
return true;
}
while(p2 && p2->next){
p1 = p1->next;
p2 = p2->next->next;
}

struct ListNode *prev, *curr, *n, *h2;
prev = NULL;
curr = p1->next;
h2 = curr;
while(curr){
n = curr->next;
curr->next = prev;
prev = curr;
curr = n;
}
p1 = prev;
while(p1){
if(p1->val!=p2->val){
return false;
}
p1 = p1->next;
p2 = p2->next;
}

return true;

}
```