Back to course home
0% completed
Vote For New Content
Problem 4: Find if Doubly Linked List is a Palindrome (easy)
Problem Statement
Given a doubly linked list, determine whether it is a palindrome.
A doubly linked list is a palindrome if it reads the same backward as forward, utilizing the previous and next pointers of the nodes.
Examples
-
Example 1:
- Input: 1 <-> 2 <-> 3 <-> 2 <-> 1
- Output: true
- Justification: The list reads the same backward as forward.
-
Example 2:
- Input: 1 <-> 2 <-> 2 <-> 3
- Output: false
- Justification: Reading backward, the list is 3 <-> 2 <-> 2 <-> 1, which is not the same as reading forward.
-
Example 3:
- Input: 1 <-> 1 <-> 1 <-> 1
- Output: true
- Justification: All elements are the same, so the list is a palindrome.
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible