Questions tagged [palindrome]
Any sequence of units (typically letters or numbers) that are read the same way forward or backward.
259
questions
30
votes
9
answers
58k
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:
...
26
votes
6
answers
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 ...
25
votes
5
answers
2k
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 ...
21
votes
10
answers
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?)...
18
votes
8
answers
5k
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 ...
17
votes
5
answers
25k
views
Longest palindrome in a string
Please be brutal, and judge my code as if it was written at a top 3 tech company, straight out of college. (The method signature, and input parameter is given by the problem, so don't worry about that)...
17
votes
3
answers
18k
views
Return the largest palindrome from the string
Here is the question: find the largest palindrome from a string.
Ex:
ABCBAHELLOHOWRACECARAREYOUILOVEUEVOLIIAMAIDOINGGOOD
Result:
...
16
votes
3
answers
3k
views
The Love-Letter Mystery
Problem Statement
James got hold of a love letter that his friend Harry has written for
his girlfriend. Being the prankster that James is, he decides to
meddle with it. He changes all the words ...
15
votes
5
answers
6k
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'...
13
votes
10
answers
8k
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 ...
13
votes
4
answers
11k
views
Palindrome Checker in Java
My objective is to take a string as input and determine if it is a palindrome. I'm wondering how I could improve this code (efficiency, bugs, etc). I'm relatively new to Java so I'm expecting that my ...
13
votes
3
answers
2k
views
Optimisation of palindrome
My program takes as first input the number of test cases, n. For the following n inputs, I output the smallest positive integer that has to be added to the input to make the input a numeric palindrome....
12
votes
3
answers
805
views
Searching for pseudo-palindromes ("semordnilaps")
I was interested to know which words of the English language, when spelled backwards, are still valid words (e.g. "drawer", which when spelled backwards is "reward"), so I wrote a small program to go ...
12
votes
4
answers
4k
views
Checking for a palindrome
What I'm basically wondering is if there's anything that is possible to improve in this C++ code:
...
12
votes
4
answers
12k
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 ...