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.

223 questions
Filter by
Sorted by
Tagged with
336 views

Checking for one- or two-dimensional palindrome strings

I am new to Python and I would like some comments to the following code. It is for checking if a string is a palindrome (in one or two dimensions). ...
95 views

Code Chef RAINBOW Palindrome

Problem Determine whether an array is "Rainbow", i.e. it has the following structure: First a1 elements equal 1. Next a2 elements equal 2. Next a3 elements equal 3. Next a4 elements ...
406 views

Counting ways to divide a word into palindrome blocks

I wrote this program as a solution to the 2015 British Informatics Olympiad question on "block" palindromes. Brief overview of the task: A palindrome is a word that shows the same sequence of ...
2k views

Determining if a palindrome exists in a linked list using recursion

Summary of code: This code recurses through half of the LinkedList, "adding" the left half node's to the call stack. Then, once at the middle, the code returns the ...
198 views

Implement a function to check if a linked list is a palindrome in c++

This is working example, I'm interested in mostly in knowing if there is any c++ related improvements you guys suggest? Also, do you think its better to solve this question iteratively or interviewer ...
90 views

Checking for a palindrome in any sub-range of a range

This is my attempt at answering "Palindrome from all the substrings" which asks to detect if a string contains a palindrome as a substring. The algorithm implemented here is the one described in its ...
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 ...
180 views

Checking if a number is palindrome or not in Java

Got this question in a technical interview and here is my solution: ...
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 ...
387 views

Checking if a string is a palindrome

This is the code for checking if a string is a palindrome. The execution time, for sample cases, is 0.40358 seconds. What must be done to increase the performance? ...
170 views

Palindromic game in Python

This is just a little palindromic game that searches all palindromic numbers in ur random generated list. Feel free to give me some advice. ...
9k views

Palindrome-testing Java program for an interview

In an interview I was asked to write a function that would take an input word and return true if the word is a palindrome. At first I used an approach using ...
1k views

Length of longest palindrome subsequence

I had an interview, where I was asked to solve to this question: Given an string str, find the maximum length of palindrome subsequence. Example: >if str = 'abcda': maximum_length = 3 '...
6k views

Close to the metal C++ Palindrome Program

I am attempting to reinvent the wheel by writing my own palindrome checking program in C++, using only basic loops and mathematical operations. I have arrived at a solution, but was wondering if it's ...
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 ...
44 views

Complexity for two approaches of finding next biggest palindrome of a number

I have come up with a problem online about the next biggest palindrome of a number and i have solved the problem by two different approaches in python. The first one is, ...
5k views

Finding the longest palindromic substring

I have the following code that works correctly. I am wondering if there is a simpler way to go about implementing my solution and/or if there is anything that looks non-standard in my code. If anyone ...
616 views

Finding palindromes and reverse strings in C

I've created a program that will find if a word is a palindrome or a reverse string (emordnilap). How it works: The palindrome part works by reversing the string,...
727 views

Find all sub matrices of type N*M in it which are palindromic

Today I had an interview, where I was asked to solve this question. A $N*M$ matrix is called a palindromic matrix, if for all of its rows and columns, elements read from left to right in a row are ...
357 views

SPOJ: smallest palindrome larger than a given number

I am working on the SPOJ palindrome question. I'm using JAVA to solve it. The problem: A positive integer is called a palindrome if its representation in the decimal system is the same when read ...
1k views

Leetcode 125. Valid Palindrome (better performance?)

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 ...
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 ...
252 views

Parallel brute-force solution for Project Euler 4 (Largest palindrome product)

The pe4Concurrent.go file given below is my first attempt at writing a concurrent programme, pe4.go is a non-concurrent implementation of the same algorithm for comparison purposes. The algorithm ...
1k views

Valid palindrome solution

I'm working on this valid palindrome problem. Any advice on code bug, better idea for low algorithm execution time complexity, code style, etc. are highly appreciated. Problem Given a string, ...
554 views

Check if a linked list is a palindrome in Scala

The problem: Palindrome: Implement a function to check if a linked list is a palindrome If it's a palindrome, the list must be the same backwards and forwards Below is the code I wrote: ...
5k views

Get all possible palindromes in C#

As the title says, the goal is to get all the possible palindromes of a string in C#: ...
1k views

Palindrome algorithm in C#

I had an interview yesterday where I had to write an algorithm on the whiteboard for working out if a value is a Palindrome in C#. The pressure got to me a bit but I've written my version of it in ...
532 views

Check for Palindrome string in Java

I was wondering if you can give me advice on this solution to assess if an user input string is a palindrome or not. How can I optimize this solution? ...
421 views

Checking if a number is a palindrome and is incrementing

Edit: Ok, this was a disaster of a question. I'll make sure to use timeit in the future I solved a Codewars problem that had the user check if a number was a ...
6k views

Calculate the number of palindrome numbers in the given ranges

I've written a program that calculates all of the palindrome numbers in the given range, but the code is slightly slower than needed. I've tried to improve algorithmic complexity to the best of my ...
412 views

Outputs all substrings that are palindromes in a given string, in alphabetical order without repitition

I'm currently trying to find a way to get my program to run more efficiently. If anyone has any ideas on how to optimize my program, i would appreciate it a lot. Also, the output has to display in ...
439 views

Project Euler #4 - Largest Palindrome Project - Python

I solved the HackerRank version of the Largest palindrome problem (similar to Project Euler 4) in Python: Find the largest palindrome made from the product of two 3-digit numbers which is less than ...
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 ...
961 views

Check if a string is a permutation of a palindrome

I see a couple of these on codereview but I was hoping my way hasn't yet been encountered: ...
1k views

Check string is permutation of palindrome

I assume there can be space in between and I have ignored that. Also, there will be only lower case characters in the string. My logic: There can be only one occurrence of odd number of character ...
1k views

Finding the longest palindrome from the given string

Recently I came across this problem which instructs me to find the longest substring which is a palindrome: As we all know, a palindrome is a word that equals its reverse. Here are some examples ...
529 views

Number of possible palindrome sequences

Here is the problem description from hackerearth.com: Rohan loves Palindromes. Palindrome is a string that read same forward and backward. For example abba is ...
4k views

Check if a string is a permutation of a palindrome using Python

This is a solution to exercise 1.4 from Cracking the Coding Interview written using Python 3. Given a string, write a function to check if it is a permutation of a palindrome. Example: 'Tact Coa' ...
468 views

Project Euler #4 - finding the largest palindrome from the product of two n-digit numbers

Project Euler Problem #4: "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 from ...
92 views

PE4: Largest Palindrome Product (Clojure)

I solved Project Euler 4 using Clojure Lisp. 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 ...
1k views

Simple Input Text Analysis

I've started learning java. I've written a small program I've done in C before. It's simple input analysis. If there is number, program checks if number is prime. Then write number: (value of input ...
1k views

The Palindromic Odometer Puzzler: A Programmatic Solution

That is a programmatic solution to a puzzler from Car Talk, its summary is: "I noticed that the last 4 digits were palindromic. I drove a mile, and the last 5 were palindromic. I drove another ...
499 views

Palindrome-inize a number

For example if I start with the number 146. I first reverse it, so it becomes 641. Then I add this to the original number to ...
385 views

Ruby solution to Project Euler Problem #4: Largest palindrome product

I've solved the Project Euler Problem #4, but I'd like some tips as to how to make this more efficient. I am a beginner to Ruby, so please be nice about the stupid stuffs (but still tell me about it). ...
122 views

Longest palindrome O(n^2)

After getting comments on my previous implementation, I have tried to implement with DP. But without using matrix. I am not doing any boundary checks on the string just wanted to see if I am missing ...
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 ...
2k views

Finding the index of the character whose removal will make a palindrome

Before I get into describing by problem I'd like to point out I found this question under c++ tag. But the solution of that question is already implemented in my ...
126 views

Finding product palindromes

I am new to perl and want some help in tuning this script if possible cause it takes time if I increased my array. also if I use warnings I get a lot of warnings ...