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

learn more… | top users | synonyms

3
votes
1answer
70 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 ...
5
votes
2answers
58 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, ...
1
vote
2answers
53 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: ...
1
vote
1answer
129 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#: ...
2
votes
3answers
99 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 ...
4
votes
4answers
108 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? ...
1
vote
1answer
58 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 ...
7
votes
4answers
148 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 ...
3
votes
2answers
51 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 ...
1
vote
1answer
82 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 ...
7
votes
6answers
1k 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 ...
10
votes
2answers
372 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: ...
1
vote
1answer
138 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 ...
1
vote
2answers
100 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 ...
4
votes
2answers
129 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 ...
3
votes
2answers
399 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' ...
2
votes
1answer
83 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 ...
6
votes
1answer
40 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 ...
3
votes
2answers
108 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 ...
5
votes
1answer
179 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 ...
9
votes
1answer
434 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 ...
5
votes
4answers
107 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). ...
0
votes
0answers
46 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 ...
3
votes
2answers
88 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 ...
3
votes
2answers
265 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 ...
6
votes
2answers
118 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 ...
0
votes
0answers
45 views

Palindromic prime search using the Sieve of Atkins

I am working on a project that deals with prime numbers and am currently looking for a way to make the function max_palprime() work faster and possibly simpler. ...
7
votes
3answers
198 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 ...
8
votes
3answers
242 views

Project Euler 4: Largest palindrome product

This solves Project Euler 4: Largest palindrome product using C# (specifically, using LINQPad). Any and all suggestions for improvements to either the C# code or the math/algorithm are very welcome. ...
0
votes
0answers
64 views

Time limit exceeded for solving longest palindromic substring by dynamic programming

I have seen plenty of longest common substring search code by dynamic programming and it is an O(n^2) operation. My motivation is to solve leetcode problem longest-palindromic-substring by this ...
6
votes
2answers
122 views

Longest palindrome in an array

I am new to programming, and think this code could be improved upon. Any suggestions? ...
3
votes
1answer
287 views

Hackerrank Funny String python solution

"Funny String" problem from Hackerrank Suppose you have a String, \$S\$ of length \$N\$ indexed from \$0\$ to \$N-1\$. You also have some String, \$R\$, that is the reverse of \$S\$, where \$S\$ is ...
4
votes
1answer
141 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 ...
5
votes
2answers
237 views

Palindrome evaluator in C++

I started learning C++ a few days ago, and this is my first full program. It takes in words until an end-of-file character prompt is given, and then outputs which of those words are palindromes and ...
1
vote
0answers
73 views

Longest palindrome subsequence

This algorithm finds the longest palindrome that is a subsequence of a given input string in \$\Theta(n^2)\$. Example Input: character Output: ...
3
votes
1answer
101 views

Faster palindrome checker in Java

I wonder if there could be a faster palindrome checker in Java. The best one I have is O(n/2) which is O(n) eventually: ...
6
votes
1answer
138 views

Palindromes that are sum of consecutive squares

I have been working on a Project Euler: 125, which took me ages to solve. The problem and source are cited below The palindromic number 595 is interesting because it can be written as the sum of ...
3
votes
2answers
116 views

Largest palindrome product

From the Project Euler challenge series: 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 ...
1
vote
1answer
284 views

Rearrange characters of a string into a palindrome, if possible

I have written Python code which works absolutely fine but I am looking for other ways to do this: ...
1
vote
2answers
116 views

Finding palindromes and the longest word in a string

I have two little projects that I've been working on. One is to find all palindromes: ...
3
votes
1answer
113 views

Determining if a string is a palindrome of a permutation

I wrote code to determine if a string is a palindrome of a permutation. This exercise was taken from Cracking the Coding Interview. I'm looking for any tips on improving it. ...
-1
votes
1answer
75 views

Determining whether a string can be rearranged into a palindrome

For a string, count the number of occurences of each character. If at most one character has odd count then the string can be a palindrome else it's not. ...
4
votes
3answers
169 views

Check for palindrome in singly linked list

Looking for code review, optimizations and best practices. Node.java ...
3
votes
1answer
67 views
3
votes
2answers
183 views

Checking if a single linked list is a palindrome in C++

The following is my first try at this classical interview question. It is quiet different from the solutions Gayle Laakmann provides in her book, and in another question on stackoverflow, someone ...
3
votes
5answers
434 views

Python palindrome checker

This is my palindrome-checker that is doing what it should do. If you have any additional suggestions, please let me know. ...
2
votes
1answer
77 views

196-Algorithm Program

Attempting to see whether using 196 as a respectively in my program will have a result or not, I made a simple function to test it. Now the 196-Algorithm requires ...
2
votes
3answers
312 views

Reverse digits and add until a palindrome appears

The following code is a C solution to the following problem UVA 10018. The Problem The "reverse and add" method is simple: choose a number, reverse its digits and add it to the original. If ...
1
vote
2answers
134 views

Longest palindromes

I've been tasked to solve this exercise lately, and this is what I wrote: ...