# \#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`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up