Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    234 - Palindrome Linked List\.

    Easy

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

    Example 1:

    Input: head = 1,2,2,1

    Output: true

    Example 2:

    Input: head = 1,2

    Output: false

    Constraints:

    • The number of nodes in the list is in the range <code>1, 10<sup>5</sup></code>.

    • 0 &lt;= Node.val &lt;= 9

    Follow up: Could you do it in O(n) time and O(1) space?

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Boolean isPalindrome(ListNode head)
      final ListNode reverse(ListNode head)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait