标签:
Given a singly linked list, determine if it is a palindrome.
Follow up:
Could you do it in O(n) time and O(1) space?
O(n)空间:存成数组后比较
class Solution: # @param {ListNode} head # @return {boolean} def isPalindrome(self, head): temp = [] while head: temp.append(head.val) head = head.next return temp == temp[::-1]
Leetcode 234 Palindrome Linked List
标签:
原文地址:http://www.cnblogs.com/lilixu/p/4635010.html