Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Problem 4: Find if Doubly Linked List is a Palindrome (easy)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

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

  1. Example 1:

    • Input: 1 <-> 2 <-> 3 <-> 2 <-> 1
    • Output: true
    • Justification: The list reads the same backward as forward.
  2. 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.

3

.....

.....

.....

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