The Stack Overflow podcast is back! Listen to an interview with our new CEO.

# Questions tagged [palindrome]

Any sequence of units (typically letters or numbers) that are read the same way forward or backward.

24 questions
Filter by
Sorted by
Tagged with
4k views

### Project Euler Problem #4 - Palindromic number

The problem is as follows: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made ...
412 views

### Improving time complexity of finding the longest palindrome in Python

The Longest Palindromic Substring challenge from InterviewBit: Given a string S, find the longest palindromic substring in S. where a "substring" must be contiguous, and in case of ties the first ...
56k views

### Check a string to see if it is a palindrome

I have written two code pieces to check if a given string is a palindrome: ...
6k views

### Tests for palindromes in C and C++

A question I've been asked on interactive phone screens is to code a test to determine whether a string is a palindrome or not. I am providing two examples here: one in C and one in C++. They both ...
5k views

### Palindromes in C

The function tests whether or not the provided string is a palindrome, and the main function just times how quick it is (after all, C's supposed to be quick, right?)...
1k views

### Count distinct primes, discarding palindromes, in under 2 seconds

Problem Statement Generate as many distinct primes P such that reverse (P) is also prime and is not equal to P. Output: Print per line one integer( ≤ 1015 ). Don't print more than 106 ...
14k views

### Return the largest palindrome from the string

Here is the question: find the largest palindrome from a string. Ex: ABCBAHELLOHOWRACECARAREYOUILOVEUEVOLIIAMAIDOINGGOOD Result: ...
1k views

### Test if a string is a palindrome

I got this out of an article on interviews / code challenges. The challenge text goes like this: A palindrome is a word, phrase, number, or other sequence of characters which reads the same ...
13k views

### Determining if a sentence is a palindrome

The biggest problem I see in checking palindromes on the Internet is when the user inputs a palindrome sentence or phrase and the program returns a wrong output. So for me, I tried to optimize ...
249 views

### Determining if a sequence is a palindrome

To complement this Java question on palindrome identification, I came up with this C++(14) version: ...
5k views

### Palindrome Checker with Stack

In my answer to this question, I wrote a new solution. Personally, I would not use a stack, but given that a stack was required, how good is this solution? In this solution, I add half of the word, ...
2k views

### Generalized Project Euler #4: Largest palindrome from product of two n-digit numbers in Python

This solves Project Euler 4: Largest palindrome product using Python (not limited to 3 digit numbers). I need suggestions for improvements to either the Python code or the math/algorithm since time of ...
4k views

### Finding the largest palindrome from the product of two n-digit numbers

The program finds the largest palindrome made from the product of two n-digit numbers, where n is specified by the user. The code included works, however, when the user enters 5 or greater, the ...
394 views

### Leetcode 125. Valid Palindrome

Problem statement Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a ...
189 views

### Project Euler #4 in Haskell

Project Euler #4 asks: Find the largest palindrome made from the product of two 3-digit numbers. The code is as follows: ...
431 views

### Check if a string is palindrome or two strings are the opposite of each other

I made a function which checks if a word is the opposite of each other (ex: word and drow) and then realized that with minor changes it could also be used to detect if a word is palindrome. They both ...
422 views

### Palindrome from all the substrings

This Problem is from https://www.codechef.com/problems/PRINCESS . The Problem in brief - i am given a string of length N. I have to check among all the the substrings that whether a substring exist ...
268 views

### Largest palindrome in the string

There are a lot similar questions out there. However, I wanted to get comments on my code. My implementation (as I believe) is simpler than the other complex ones as mine is $O(n^2)$. My approach ...
285 views

### Palindrome numbers - Project Euler Problem 4

Project Euler Problem #4: Largest palindrome product: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. ...
1k views

### Removal of a character to make a string a palindrome

This code determines which index for a given string if that character is removed will produce a palindrome string. For eg s = "baa" After removing b the string "aa" is palindrome. Here ...
4k views

### Palindromes with stacks

I'm creating a simple function to verify whether or not a string is a palindrome, and must use stacks in solving it. ...
2k views

### Largest palindrome made from the product of 3-digit numbers

I am given a task to write a program to find the largest palindrome made from the product of two 3-digit numbers. How can I improve this code? ...