Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

74. Palindrome Linked List

EasyDay 22 of 60Linked List

Given the head of a singly linked list, return true if its values read the same forwards and backwards. Can you do it in O(n) time and O(1) extra space?

Example 1
Input: head = [1,2,2,1]
Output: true
Example 2
Input: head = [1,2]
Output: false
Constraints
  • The list has 1 to 10^5 nodes
  • 0 <= Node.val <= 9
Hints
Frequently asked at: Meta, Amazon, Microsoft, Adobe
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min