DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
easy
LinkedList

Palindrome Linked List

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Palindrome Linked List** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Find mid + reverse second half + compare **Edge Cases to Consider:** - (1) Single node - (2) Two nodes - (3) Even vs odd length

Examples

Example 1
Input: [1,2,2,1]
Output: true
Explanation: Even-length palindrome
Example 2
Input: [1,2]
Output: false
Explanation: Two different nodes
Example 3
Input: [1]
Output: true
Explanation: Single node always palindrome

Constraints

  • ▪The number of nodes in the list is in the range [0, 500]
  • ▪-100 <= Node.val <= 100
  • ▪Solve in-place without copying node structures

Watch Out For Edge Cases

  • ▪Single node
  • ▪Two nodes
  • ▪Even vs odd length
Frequently Asked At
AmazonMicrosoftMetaAdobeTCS