Palindrome Linked List

Given the head of a singly linked list, return true if it is a palindrome or false otherwise.

Constraints

  • The number of nodes in the list is in the range [1, 10^5].
  • 0 <= Node.val <= 9
Saving… · 9 lines
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next

class Solution:
def isPalindrome(self, head: ListNode) -> bool:

Console

Click Run to execute sample tests.