Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [palindrome]

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

0
votes
0answers
15 views

Split string into as few substrings as possible such that each substring is a palindrome

The task Given a string, split it into as few strings as possible such that each string is a palindrome. For example, given the input string racecarannakayak, return ["racecar", "anna", "...
0
votes
1answer
57 views

Why does my function think that “uiouioiu”is a plaindrome? [on hold]

I was reading Introduction to Computation and Programming using Python and there in an exercise, we had to write a function which would tell us if a given word is a palindrome or not, recursively. ...
4
votes
3answers
380 views

Determine whether an integer is a palindrome

The task Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: ...
2
votes
0answers
63 views

Return whether a string is a palindrome if you can delete at most k elements

The task: Given a string which we can delete at most k, return whether you can make a palindrome. For example, given 'waterrfetawx' and a k of 2, you could delete f and x to get '...
11
votes
5answers
795 views

Easy to read palindrome checker

I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is \$\mathcal{O}(n)\$ but I'm not too sure ...
0
votes
0answers
81 views

Longest Palindromic Substring better approach

I have encountered to this question and applied a brute force algorithm off top of my head and couldn't find a better optimized solution. I was hoping I could get some insight to implement a better ...
1
vote
1answer
58 views

Check if given integer is a palindrome

This code checks if the given integer is a palindrome. If it is, prints given integer is a palindrome else, not a palindrome: ...
1
vote
4answers
137 views

Read a palindrome of unknown length

I have a task to write the function: int read_palindrome(); // input comes from stdin which will read one line from standard input and returns 1 if the line is a ...
2
votes
1answer
67 views

Find palindromes in circular rotated string

I'm trying to tackle a programming challenge to determine how many palindromes exist in a given string that is being rotated character by character. My solution works, but it's too slow, and I'm ...
10
votes
2answers
191 views

Determining if a string can be permuted to a palindrome

I am going through Elements of Programming Interview by Aziz, Lee and Prakash one of the questions is how to determine if a string can be permuted to a palindrome. For example ...
2
votes
0answers
124 views

Longest Palindromic Substring challenge

My code is a mix-up between dynamic programming with the HashMap and brute force with the way I reach out the results and substring. I don't know how to optimize my ...
4
votes
2answers
64 views

Solve Project Euler #4 in PHP

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 the product of two 3-digit ...
3
votes
4answers
2k views

Find longest Palindrome substring

I am preparing for technical interview and I found this question on geeksforgeeks, but I did not understand their solution. So, I have written my own solution. I want to optimize this code. ...
-2
votes
1answer
68 views

Find the first palindrome larger than the given number

Question Input number of test cases. Input each test case and output its next palindrome number. Link: https://www.spoj.com/problems/PALIN/ Language Used: C++14 (gcc 6.3) My code ...
1
vote
1answer
46 views

A program that checks for Palindromness

Yes, I made it up. This program checks if an entered string is a palindrome or not by assigning a char variable the characters ...
2
votes
2answers
94 views

Find a palindromic string in C

This program tests whether a string is a palindrome or not. Can there be any improvements or shortcuts that can be used in the program. You can give any type of string as input. The program finds does ...
10
votes
5answers
431 views

Circles of numbers

I have a function: ...
7
votes
3answers
1k views

The Next Palindromic number

I have incremented an integer in the function nextpalin() and converted it into a std::string for finding whether it's a ...
0
votes
1answer
125 views

Find largest palindrome from the product of two 3-digit numbers

I think this is a good solution to finding the largest numeric palindrome that can be formed from the product of two 3-digit numbers... But it seems like there are some improvements that we could make ...
7
votes
1answer
1k views

Check if a given linked list is palindrome

I am solving interview questions from here. Problem :Given a singly linked list, determine if its a palindrome. Return 1 or 0 denoting if its a palindrome or not, respectively. Notes:Expected ...
4
votes
2answers
681 views

Next palindromic number

I wrote a function that takes a number and finds the next palindromic number. Time complexity is currently O(n2), which is really bad. How could one make this function more efficient? ...
15
votes
5answers
4k views

Palindrome checking function

I recently did a little task for fun that required me to create a class to determine if a word is a palindrome or not. I know this is quite simple, but I'd be interested to know if a real developer (I'...
0
votes
1answer
36 views
1
vote
2answers
1k views

Count palindrome substrings

Given a string S, count and return the number of substrings of S that are palindromes. Single length substrings are also palindromes. We just have to count the substring that are palindrome. ...
0
votes
2answers
1k views

Palindrome algorithm

This code could be better? This is the algorithm: Compare the 1st character to the last character Compare the 2nd character to the second last character and so on Stop when the middle of the ...
2
votes
2answers
1k 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? ...
4
votes
2answers
484 views

Finding palindromic strings of even length

Given a string of digits. Find the length of longest substring of even length i.e. 0,2,... which is a palindrome or which can be rearranged to form a palindrome (see example below). Here is my code: ...
6
votes
2answers
1k views

Counting the number of continuous palindromic substrings

Given a string of lowercase ASCII characters, find all distinct continuous palindromic sub-strings of it. Here is my code: ...
4
votes
1answer
492 views

C++ check if Palindrome

Just did this simple application to check whether a string is a palindrome or not ...
1
vote
0answers
413 views

Python palindrome function; is it possible to write it without using string conversion?

I hope this question is okay to ask on Code Review; this is a little function I wrote in Python 2.7.12 that checks if a number is a palindrome. It works fine but I'd like to know if there is a purely ...
2
votes
1answer
59 views

Performing the Lychrel algorithm in Rust

A Lychrel number is a natural number that cannot form a palindrome through the iterative process of repeatedly reversing its digits and adding the resulting numbers. In the code below I'm trying to ...
3
votes
2answers
1k views

Find a substring which could be rearranged into a palindrome

Problem statement: To find maximum length substring in an input string which could be arranged into a palindrome, only even length palindromes are expected. Input is one line String which ...
11
votes
10answers
5k 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 ...
1
vote
0answers
83 views

C# Project Euler #4: Program that finds Largest palindrome product

So I made a code to improve my programming skills and it works just fine, but it looks chaotic for me. Is there is a better and more efficient way to do it? If you have any ideas/tips I would love to ...
5
votes
3answers
2k views

Find palindromic substrings as efficiently as possible

I've written a function to calculate all the distinct substrings of a given string, that are palindromes. The string is passed as the argument to the function. For example, the string abba is a ...
2
votes
1answer
597 views

Valid Alphanumeric Palindrome

Valid Alphanumeric Palindrome Problem (from Leetcode) Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, ...
3
votes
1answer
1k views

Palindrome implementations - iterative and recursive

I got asked this palindrome question when the interviewer wants to make sure that my palindrome can check if "Taco! Cat!" is a palindrome. In this example, my palindromes implementation needs to ...
-3
votes
1answer
245 views

My third post about Python 3 palindromes

I'm new to python3, and I tried to test if my palindrome codes work and pass most of the edge cases. so I created the following 2 python files below. When I ran the ...
4
votes
1answer
750 views

Python 3 palindrome checker

I am writing a python3 implementation of palindromes checker. ...
0
votes
1answer
915 views

Unit test cases for Python palindrome

I'm new to Python 3, and I tried to test if my palindrome code works and passes most of the edge cases, so I created the following 2 Python files. When I ran the ...
3
votes
2answers
802 views

Generating all 6-digit palindrome numbers in C++

I just finished my first homework for university where I had to create code that would generate all 6 digit palindrome numbers. Can someone who has more knowledge give me some tips where I can ...
3
votes
3answers
298 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). ...
3
votes
2answers
83 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 ...
5
votes
2answers
351 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 ...
2
votes
5answers
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 ...
2
votes
1answer
172 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 ...
3
votes
1answer
84 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 ...
3
votes
1answer
354 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 ...
0
votes
1answer
161 views

Checking if a number is palindrome or not in Java

Got this question in a technical interview and here is my solution: ...
3
votes
2answers
324 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 ...