Skip to main content


Showing posts from June, 2018

Check if a Linked List is Palindrome

In this post, We will discuss a method to check if a given string or number represented in the form Linked List is a Palindrome. First, let's see the definition of a Palindrome, A word, phrase or a sequence that reads the same backwards as forwards is called a Palindrome. eg. "MADAM", 11100111, "NURSES RUN".

Questions on palindrome, anagrams are very common in coding interviews and also very easy to solve if you have solved them before. There are a lot of methods to check If a string or a number is a palindrome or not. In this post, we will use the second method i.e pointers

First Approach: Using Stack

In this method we iterate over the string and for each character we compare the current character is same as that of character at the stack top if yes then we pop the element from the stack top else we push the current character onto the stack, after iterating over the string if the stack is empty then we can declare that the given string is a palindrome else the g…