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

Number of possible palindrome anagrams for a given word

I have to find No. of palindrome anagrams are possible for a given word. Suppose the word is aaabbbb.My approach is Prepare a hash map that contains no. of time each letter is appearing For my example it will be a--->3 b--->4 If length of…
Roshan
  • 2,144
  • 2
  • 16
  • 28
3
votes
3 answers

smallest number greater than given number which is a palindrome

This was asked in an interview. Given a number, say 900, output the smallest palindrome greater than the number, 909 in this case. I gave a brute force solution that checks every number but I'm assuming there's a better way to go about this
Aks
  • 5,188
  • 12
  • 60
  • 101
3
votes
4 answers

Next higher prime and palindrome number

Is there any suggestion on solving next higher prime and palindrome number from a given int. Here is the snippet I am trying but its a kind of slow, please suggest if you ve any good algorithm that i can test. #!/usr/bin/python …
James Sapam
  • 16,036
  • 12
  • 50
  • 73
3
votes
5 answers

How can I check if a doubly-linked list is a palindrome without using extra space?

Recently, I went for an interview and they asked me "to check if below doubly-linked list is a palindrome without using any extra storage, such as STL's linked list, stack, queue, tree, string, character arrays, etc.." I was unable to give a perfect…
Santosh Sahu
  • 2,134
  • 6
  • 27
  • 51
3
votes
4 answers

Character Pointers with Palindrome Checker in C

This is code I wrote that checks if a string is a palindrome or not. I need to revise this code so that it uses character pointers in it. Could someone give me some suggestions/tips...or show me how to do that? Thanks #include #include…
Gary Ridgway
  • 71
  • 1
  • 3
  • 6
3
votes
6 answers

Checking if a number is a palindrome

I've tried to check whether a number is a palindrome with the following code: unsigned short digitsof (unsigned int x) { unsigned short n = 0; while (x) { x /= 10; n++; } return n; } bool ispalindrome (unsigned…
user2064000
3
votes
4 answers

C++ changing variable inside while loop

I'm new to C++, and trying to go through [Project Euler][1]. I got all the way to [Problem 4][2] (impressive I know) and am having trouble with what I think is the scope of my variables inside a while loop. If you don't know, the problem asks you to…
Daniel Forsyth
  • 313
  • 2
  • 4
  • 15
3
votes
2 answers

Find number of palindromes that are anagrams in C++

I am taking part in an online programming contest for fun on http://www.hackerrank.com. One of the problems that I am working on is to find number of anagrams of a string that are palindrome as well. I have solve the problem but when I try to upload…
Richeek
  • 2,068
  • 2
  • 29
  • 37
3
votes
2 answers

Determine if input is a palindrome in C

I'm fairly new to C and I'm having a little bit of a problem. I have to write a program that takes user input and determines if the input is a palindrome. I've got the program to reverse the input, but I'm having trouble getting the strings to…
cdg53
  • 95
  • 1
  • 2
  • 5
3
votes
2 answers

How do I ignore punctuation marks and whitespace in java?

import java.util.Scanner; public class Ex3 { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.print("Please input a word: "); String Line = keyboard.nextLine(); …
user1730357
  • 355
  • 4
  • 7
  • 15
3
votes
3 answers

Generate list of all palindromic numbers of 3 digits in python

I want to generate list of all palindromic numbers of 3 digits in python. I can code this in a crude way but is there some intuitive way using list comprehension or itertools etc? And also, How to do it if it is given the number is k digits instead…
prongs
  • 9,422
  • 21
  • 67
  • 105
2
votes
5 answers

Check Palindrome using recursion

I am trying to implement a function that will check to see if a word is a palindrome Below is the code that i have tried to use. the code works for one letter words obviously and words that don't start and end with the same letter. It fails on…
Sean
  • 857
  • 1
  • 11
  • 21
2
votes
1 answer

Compile-time palindrome check

What should I do to check whether an integer array is palindrome (e.g. 1 3 10 3 1 is palindrome) in compile time? A possible framework could be: template class IntArray; template class…
27rabbit
  • 61
  • 6
2
votes
1 answer

VBA Palindrome function

I created the following function to check wether a given word is a palindrome and send back true or false. However, the function return #NAME! . Hereby the code: Option explicit Public Function palindrome(txt As String) As Boolean Dim xend As…
Bobo31
  • 31
  • 1
2
votes
1 answer

what is the time complexity of an algorithm that recursively checks if a string is a palindrome?

I have solved the problem using this algorithm and have calculated that the total number of recursive calls is n/2 since we always pass a substring of the original string with 2 less characters. The runtime complexity of the slice() function is…
WilliamG
  • 31
  • 5