Last active
December 6, 2018 06:03
-
-
Save DrynnBavis/ea62477ff707cab7e19986f01d5c3c8e to your computer and use it in GitHub Desktop.
returns true if linked list of nums is a palindrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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