Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Palindrome Linked List

Easy
linked-listtwo-pointers

Return true if a singly linked list reads the same forwards and backwards. The follow-up asks for O(n) time and O(1) space.

Input: one line of space-separated integers. Output: true or false.

Example 1
Input:
1 2 2 1
Output:
true
Example 2
Input:
1 2
Output:
false

Constraints

  • 1 ≤ list length ≤ 10^5
  • 0 ≤ node values ≤ 9
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.