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

learn more… | top users | synonyms

2
votes
3answers
103 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
85 views

Longest palindromes

I've been tasked to solve this exercise lately, and this is what I wrote: ...
8
votes
4answers
969 views

Program to Check If string is Palindrome (in C) [closed]

Just wrote a program to check if a string is Palindrome. If that's true, return 1. Else, return 0. How can I improve it? ...
3
votes
0answers
49 views

Determining if a genetic sequence is palindromic

Adding another level to my previous question on 'normal' palindrome identification, in this one I'm interested in identifying genetic palindromes. Here's my attempt: ...
4
votes
1answer
71 views

Determining if a sequence is a palindrome

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

Project Euler #4 in C++: largest palindrome product of two 3-digit numbers

Project Euler #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 ...
1
vote
2answers
75 views

Check if a linked list is a palindrome in O(n) time and O(1) space

I liked this problem because there are so many sub-problems that are interview problems in their own right-- (reverse linked list, find midpoint) ...
4
votes
1answer
53 views

Worst case runtime analysis of a string partitioning algorithm

Give all the partitionings of a string s such that every substring of the partition is a palindrome What is the time complexity of this solution? And, how can I improve my code overall? ...
3
votes
3answers
408 views

Integer Palindrome Check in C

This method should check whether a number is a palindrome or not: ...
17
votes
10answers
4k 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, ...
6
votes
1answer
105 views

Next Palindrome

I've written a function which, given a number string, returns the next largest palindrome in string form. For example, if the input string is "4738", the output ...
5
votes
2answers
381 views

Find all distinct palindromic sub-strings for a given string

I was solving a question where I had to find all possible unique palindromes of size greater than 1 for a string. I was able to come up with the solution shown below. If I am not mistaken it is an ...
3
votes
1answer
102 views

Longest palindromic subsequence by memoization

I've written some code to solve the longest palindromic subsequence problem. ...
2
votes
3answers
90 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. ...
4
votes
2answers
323 views

Find palindrome in a string

The purpose of this code is to find the largest palindrome in a string. It works fine when the string is short, but every time I test this code with 1000+ characters in a string, it takes forever to ...
4
votes
1answer
117 views

Finding palindromes in C#

This is my first foray into OOP, so I'd appreciate any kind of advice! Here is the problem description: On the first line of the input, you will receive a number specifying how many lines of ...
4
votes
2answers
109 views

Palin Pairs (Pallindrome Counting) Code

In an array of strings 'a' having 'n' strings i have to select the Palin Pairs from the given strings .for ex for input 3 bba abb abb Output=2 I am getting correct output but want to reduce time ...
3
votes
3answers
83 views

Palindrome Validator

This code returns true if the sentence is a palindrome, and false otherwise. Is there a better way of doing this? ...
6
votes
4answers
569 views

Largest palindrome that can be made from a product of 2 3-digit numbers (Project Euler 4)

This is my solution to Project Euler #4, which asks for the largest palindrome that can be made from a product of 2 3-digit numbers. I have done a brute force method, but it takes around 10-20 seconds ...
2
votes
3answers
129 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 ...
3
votes
3answers
1k views

Finding number of palindrome pairs in an array

I am trying to find the number of string pairs in an array that are palindromes. ...
3
votes
1answer
149 views

Project Euler 348: Sum of a square and a cube

Many numbers can be expressed as the sum of a square and a cube. Some of them in more than one way. Consider the palindromic numbers that can be expressed as the sum of a square and a cube, ...
7
votes
1answer
3k views

Finding all possible distinct palindromes of a string

There was some online test where I was asked about finding all possible distinct palindromes of a string. Here I had to give the count of all possible distinct palindromes of a given string ...
1
vote
2answers
88 views

Making numbers palindromic

This is a challenge I found here. You're suppose to list how many steps it takes to convert a number to a palindromic number, where each step consists of adding number to the reverse of itself. For ...
2
votes
1answer
450 views

Checking if any permutation of a string can make it palindrome

I was writing code to check if any permutation of a string can make it palindrome and came up with the following logic: ...
2
votes
3answers
110 views

HackersEarth - Reverse primes

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( ≤ 10^15 ). Don't print more than 10^6 integers in all. ...
11
votes
4answers
4k 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 ...
1
vote
2answers
87 views

Checking a numeric palindrome

Given A and B, count the numbers N such that A ≤ N ≤ B and N is a palindrome. Input: First line contains T, the number of testcases. Each testcase consists of two integers A and B in ...
4
votes
2answers
446 views

HackerRank challenge - index palindrome

I have a solution but it fails the performance for two tests. How can I speed it up? ...
8
votes
3answers
1k views

Project Euler #4 - Largest Palindrome Product in Java

I am seeing that this is actually not in accord with the difficulty level said there. Firstly I cannot list all possible improvements it could have. ...
4
votes
2answers
201 views

Largest palindrome in a string

I am working on a question in which I need to find a largest palindrome given a string. Here is the description. ...
3
votes
6answers
3k views

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

I am working on an interview question in which I need to find the largest palindrome made from the product of two 3-digit numbers. Here is the question. ...
2
votes
1answer
45 views

Palidrome checker in haskell

I decided to avoid the trivial isPalindrome lst = lst == reverse lst and tried writing a method with pattern matching and recursion. ...
1
vote
1answer
168 views

Longest palindrome in a given string using LINQ

Problem:I need to write an algorithm that will return length of longest possible palindrome from a given string. So if the input is aabbbccdfg Program output should be 7. //-->[cabbbac] Can someone ...
7
votes
4answers
2k views

Palindrome program

Given a beginning and ending point, check how many numbers are palindromic. My solution is a bit clunky. How could it be more elegant? ...
5
votes
1answer
280 views

STL-like palindrome checking

I just read this article on how to write a standard-like algorithm and wanted to try it myself by writing (as suggested in the article) an algorithm to test if a sequence given by two bidirectional ...
4
votes
2answers
412 views

Number palindrome checker

My daughter, nine, recently had some homework looking at number palindromes. Part of the assignment was to take a number, reverse it, add the two together and repeat until she got a palindrome and to ...
2
votes
1answer
834 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, ...
2
votes
4answers
314 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. ...
3
votes
3answers
531 views

Finding the next palindrome code

I have been trying recently to develop a code finding the next palindrome from a certain number. For example, if the input is 800, the output should be 808, as 808 being the next palindrome from 800. ...
10
votes
2answers
309 views

The finest integers are palindromes

Challenge: Reverse the digits of a number and add it to the original until the number is a palindrome Specifications: Your program should accept as its first argument a path to a filename. ...
3
votes
1answer
1k views

Producing a pyramid of capital letters

Now I'm reading C Premier Plus by Stephen Prata and there's an exercise 4 in chapter 6 which has no solution in the book, so I can't check if I did it properly. My code works like it should, but I ...
6
votes
2answers
643 views

Palindromes without character

You are given a string of lowercase letters. Your task is to figure out the index of the character whose removal will result in a palindrome. There will always be a valid solution. Here is my ...
3
votes
1answer
1k views

Check if string can be rearranged into a palindrome

I created a function to test whether a single word string can be a rearranged into a palindrome (doesn't have to be a real word). My logic was if the string has an even number of letters, then each ...
7
votes
5answers
502 views

Palindrome checker using a sentinel loop

This is my first submission and have completed one quarter of Java programming. I have an assignment to create a Palindrome Checker. Fairly straight forward, I had that portion of the code figured ...
2
votes
2answers
114 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: ...
4
votes
5answers
3k 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 ...
2
votes
1answer
103 views

Code that finds the largest palindrome from two three-digit factors

My code is really ugly, but I don't know how to make it better. ...
4
votes
2answers
355 views

Palindrome Checker Algorithm

Here is an example of how I solved this problem (though this is not the only nor the best way by any means) for an assignment where it was also requisite to determine if a string was a reverse prefix ...
5
votes
1answer
969 views

Anagram palindrome checking

I need to figure out if any anagram of the string can be a palindrome or not. Ideas: It relies on two observations: Frequency of every character in the string is even, if length of the string is ...