赞
踩
- /**
- * Definition for singly-linked list.
- * type ListNode struct {
- * Val int
- * Next *ListNode
- * }
- */
- func isPalindrome(head *ListNode) bool {
- var list []int
- for head!=nil {
- list=append(list,head.Val)
- head=head.Next
- }
- for i,j:=0,len(list)-1;i<j;i,j=i+1,j-1 {
- if list[i]!=list[j] {
- return false
- }
- }
- return true
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。