LintCode:回文链表

来源:互联网 发布:php call stack 编辑:程序博客网 时间:2024/05/16 07:26

LintCode:回文链表

# Definition for singly-linked list.# class ListNode:#     def __init__(self, x):#         self.val = x#         self.next = Noneclass Solution:    # @param head, a ListNode    # @return a boolean    def isPalindrome(self, head):        if head == None:            return True        L = []        p1 = head        while p1 != None:            L.append(p1.val)            p1 = p1.next        if L == L[::-1]:            return True        return False
0 0
原创粉丝点击