Questions tagged [palindrome]

A word, phrase, number, or other sequence of units that may be read the same way in either direction, forward or backward.

A word, phrase, number, or other sequence of units that may be read the same way in either direction, forward or backward.

Spacing and punctuation is generally ignored when attempting to determine whether the potential palindrome under consideration is in fact a palindrome. One such example is:

I, madam, I, made radio - so I dared! Am I mad? Am I?

(from http://www.joe-ks.com/palindromes.htm)

1763 questions
3
votes
1 answer

Check if a singly linked list is a palindrome or not in C

I'm trying to check if a singly linked list is a palindrome or not. The constraints are - the algorithm has to be in linear time and constant space. The basic algorithm I'm using is as below - Use fast & slow pointers to divide the list into two…
rurtle
  • 411
  • 4
  • 18
3
votes
5 answers

Check if string is a palindrome after removing one character. My working solution is too slow

I cant seem to find a proper solution to an exercise. The exercise asks to create a method that returns true if a string can be a palindrome by removing one character. I have a solution that works but fails tests of large (100,000 character) strings…
Rocky
  • 132
  • 1
  • 2
  • 9
3
votes
1 answer

Determining if a string is a palindrome

I wanted to know where my logic is faulty. A string (str) is taken as an argument (the string could be lowercase, uppercase, with commas and periods) and set equal to var string. It is then reversed and if it equals the original string then the…
Codes316
  • 303
  • 3
  • 14
3
votes
1 answer

Prolog palindrome

I'm trying to write a palindrome function in Prolog. I know I could just use something like palindrome(List) :- reverse(List, List). But I'm trying to figure out a way without using the built in reverse. I've created my own reverse rule: rev([],…
user3186023
3
votes
2 answers

Find the longest non-palindromic substring in a string

I need to find out the longest non-palindromic substring ( a string which itself isn't a palindrome, doesn't matter whether any substring of it is) in a string, in O(n**2) or less time. I can come up with the simple brute force algorithm, finding…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
3
votes
6 answers

Checking for palindrome string in c

I am accepting a string as a command line argument. I want to check whether the inputted string is a palindrome or not and print the result. I have written the following code. But its displaying the result 'not palindrome' for all…
Khushboo
  • 285
  • 3
  • 5
  • 12
3
votes
1 answer

Palindrome number product of two 3-digit numbers - Project Euler Solution 4 - Brute Force not working

I am using this code to solve problem. 4 on Project Euler. The problem reads: 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…
Fᴀʀʜᴀɴ Aɴᴀᴍ
  • 6,131
  • 5
  • 31
  • 52
3
votes
1 answer

LISP - recursive palindrome

I'm trying to write a recursive palindrome function. The code works using two function as follows: (set str(a b c d)) (defun reverseString (l) (cond ( (null l) nil) (T (append (reverseString (cdr l)) (list (car l)))) …
nikebOxer
  • 33
  • 4
3
votes
3 answers

Why we can't reliably test for palindromes on one pass

I came across the concept of "palindrome". I try to understand by reading through wikipedia http://en.wikipedia.org/wiki/Palindrome#Computation_theory The paragraph caughts my attention This means that it is impossible for a computer with a finite…
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
3
votes
8 answers

Recursive method for palindrome checkup

Is it even possible to define a recursive method for palindrome checkup with the following argument list? int testPalindromeRecursive(char* str, int len) { ... } Note: no external sub-functions or global variables have to be used I think this is…
neuronalbit
  • 358
  • 1
  • 3
  • 15
3
votes
4 answers

How to check if a sequence could be turned into a palindrome

I have to find if a list can be a palindrome. The first part of my program sorts the list. A = [0, 99, 97, 97, 99, 100, 100, 0] # sorted: B = [0, 0, 97, 97, 99, 99, 100, 100] This list can be a palindrome because it can be reordered to: [0, 97,…
BioShock
  • 763
  • 2
  • 13
  • 33
3
votes
2 answers

Proving that a reversible list is a palindrome in Coq without exists tactic

For an exercise in software foundation I want to prove the following theorem : Theorem rev_pal {X:Type} : forall (l:list X), l = rev l -> pal l. pal is defined as follow : Inductive pal {X:Type} : list X -> Prop := | pal_nil : pal [] | pal_one :…
Saroupille
  • 609
  • 8
  • 14
3
votes
2 answers

Can an empty string be considered a palindrome

I have been asked to give a context-free grammar that generates the following language (The alphabet is {0, 1}: { w| w is a palindrome } To answer this correctly, I need to know if I can consider an empty string to be a palindrome. Thank you.
Frank Ibem
  • 828
  • 1
  • 11
  • 19
3
votes
1 answer

Palindrome Test: Debugging

I'm having trouble figuring out the bug(s) in my code. I know there is one except I'm not sure what it is. I am new to coding and this is only my second semester, my professor had us skip to the end of the book to learn recursion however in the labs…
3
votes
2 answers

Arranging word to formpalindrome

Hello i´ve been trying to form palindromes from this input: String[] text ={"ivcci", "oyotta", "cecarar","bbb","babbbb"}; getPalindrome(text); and i need to rearrange all words in array to produce this output civic -1 rececar bbb bbabb the method…