# Runtime: 80 ms beats 100.00% of Python3 submissions, O(n) time and O(1) space


  • 0
    M

    Runtime: 80 ms beats 100.00% of Python3 submissions, O(n) time and O(1) space

    class Solution:
        def isPalindrome(self, head):
            """
            :type head: ListNode
            :rtype: bool
            """
            if not head:
                return True
            a = []
            curr_node = head
            while curr_node:
                a.append(curr_node.val)
                curr_node = curr_node.next
            return a == a[::-1]
    

    https://leetcode.com/submissions/detail/150411924/


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.