---
# System prepended metadata

title: \#234 Palindrome Linked List
tags: [leetcode, leetcode-easy]

---

# \#234 Palindrome Linked List
## *檢查是否為回文linked list*
## Log
 - build 20210510 by syhuang

## xxx
 - xxx
```javascript=
```
## 初見
 - 用array存linked list的所有元素, 再利用shift+pop檢查回文
```javascript=
var isPalindrome = function(head) {
    var a = [];
    var p = head;
    while(p){
        a.push(p.val);
        p = p.next;
    }
    while(a.length>1){
        if(a.shift()!=a.pop()) return false;
    }
    return true;
};
```
## 備註
 - [O(n)time & O(1)space解](https://leetcode.com/problems/palindrome-linked-list/discuss/64603/Javascript-reversing-linked-list-solution)
## 參考
###### tags: `leetcode`, `leetcode-easy`