Check if the doubly linked list reads the same forwards and backwards!
Hi! I'm Teju 👋 We need to determine if a doubly linked list is a palindrome — meaning it reads the same from both ends.
Example: 1 ↔ 2 ↔ 3 ↔ 2 ↔ 1 → true
1 ↔ 2 ↔ 3 ↔ 4 → false
Input: N (number of nodes), followed by N values
Output: true or false
Advantage of doubly linked list: We can traverse from both ends easily!
Since it's doubly linked, we can use two pointers: one starting from the head (left) and one from the tail (right).
Move them towards the center, comparing values at each step.
Enter the number of nodes and values to build the list...
Is Palindrome?