234.E 回文链表
思路
Code
func isPalindrome(head *ListNode) bool {
var nums []int
for head != nil {
nums = append(nums, head.Val)
head = head.Next
}
i, j := 0, len(nums)-1
for i < j {
if nums[i] != nums[j] {
return false
}
i++
j--
}
return true
}Last updated