Skip to content

Instantly share code, notes, and snippets.

@DrynnBavis
Last active December 6, 2018 06:03
Show Gist options
  • Select an option

  • Save DrynnBavis/ea62477ff707cab7e19986f01d5c3c8e to your computer and use it in GitHub Desktop.

Select an option

Save DrynnBavis/ea62477ff707cab7e19986f01d5c3c8e to your computer and use it in GitHub Desktop.
returns true if linked list of nums is a palindrome
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def isPalindrome(self, head):
"""
:type head: ListNode
:rtype: bool
"""
vals = []
while (head != None):
vals.append(head.val)
head = head.next
return vals == vals[::-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment