Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Palindrome Linked List

Medium Acceptance 41.48% Points 30.00

Given a singly linked list of integers. The task is to check if the given linked list is palindrome or not.

Examples
Example 1

Example 1

Input: LinkedList: 1 -> 2 -> 3 -> 2 -> 1

Output: true

Explanation: The linked list reads the same forward and backward, making it a palindrome.

Example 2

Example 2

Input: LinkedList: 1 -> 2 -> 3 -> 4 -> 5

Output: false

Explanation: The linked list is not symmetric, so it is not a palindrome.

Hints
Hint 1
Expected Time Complexity: O(n)
Hint 2
Expected Space Complexity: O(1)
Constraints
  • 1 <= number of nodes <= 10^5
  • 1 <= node->data <= 10^3
Companies
Amazon Microsoft Adobe
Topics
Linked List
Solution.cs C#JavaPythonC++Javascript

Unlock the code editor

Sign in to write, run, and submit your solution against the full test suite.

  • Run code against sample & hidden test cases
  • Save submissions and track your streak
  • Compare with editorial & community solutions