Murder for a jar of red rum? Funny. Makes me think of the movie, “The Shining“. Let’s have fun with a palindrome problem.

This problem was asked by Google.

Determine whether a doubly linked list is a palindrome.

What if it’s singly linked? For example, 1 -> 4 -> 3 -> 4 -> 1 returns True while 1 -> 4 returns False.

Solution

Note: The upside to the second method is that it uses constant space. The downside is that we destroy the original list.

This problem was provided by Daily Coding Problem. Get exceptionally good at coding interviews by solving one problem every day.

Leave a Reply