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
2
votes
1 answer

Clojure. Cursive. No debugger?

I'm learning Clojure using "Clojure From the Ground Up" by Kyle Kingsbury. The VERY FIRST exercise is to write a Clojure routine to test if a given string is a palindrome. I wrote something…
LionelGoulet
  • 557
  • 2
  • 13
2
votes
1 answer

Problem using shifting bit (check if a binary number is palindrome)

I need help with a code that check if a binary number is palindrome. Suppose that the input is 21 (10101). In the function i do that: -copy the value of num1 to num2 -now num1 is 00010101 and num2 is 00010101 -shift(right) the bit of num1 while…
Riccardo
  • 192
  • 2
  • 2
  • 11
2
votes
2 answers

Get all possible palindromes from a given string

A substring is a contiguous range of characters within a string. Now I need to find out how many substring that can be re-arranged that can form a palindrome. For example: For input - aabb a aa aab (because after re-arranging it becomes aba) aabb…
learner
  • 6,062
  • 14
  • 79
  • 139
2
votes
2 answers

Trying to find the longest palindrome for this input

Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This is case sensitive, for example "Aa" is not considered a palindrome here. Note: Assume the length…
anonymous
  • 65
  • 1
  • 8
2
votes
2 answers

Find total number of palindrome of size N using K letters

Find total number of palindromes of length N using K letters such that any prefix of length 2 to N-1 is not a palindrome. tried K*((K-1)^(Math.ceil((N-2)/2))) first place can hold K letters. second can K-1 except one that is at first place.…
2
votes
1 answer

Code Not Printing the Set When Map() is Used

Q:1] Why are the print statements (commented) resulting in print(mapped) to not print the set? If those lines # print(list(word)) # print(list(palindrome)) are not-commented out, then the output results in: ['N', 'u', 'r', 's', 'e', 's', 'r',…
RSSregex
  • 179
  • 7
2
votes
2 answers

Convert string to palindrome with fewest number of insertions

This is a question from https://www.dailycodingproblem.com/: Given a string, find the palindrome that can be made by inserting the fewest number of characters as possible anywhere in the word. If there is more than one palindrome of minimum…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
2
votes
3 answers

C++ Recursion and Pointer Problems

First off, this is for an assignment. What's required: 1.Take in string input 2. copy string (stripping out white space, punctuation, and covert all characters to uppercase in the process) 3. Then determine if this copied string is a…
okkv1747vm
  • 91
  • 1
  • 7
2
votes
1 answer

Code works in console but not in Hackerank

My code works in console but gives the wrong result in hackerank Problem: Print count of all substrings that are palindromes from a string function isPalindrome(str) { var len = str.length; var mid = Math.floor(len / 2); for (var i =…
GeekInTraining
  • 135
  • 1
  • 1
  • 5
2
votes
5 answers

Palindrome with even numbers

I've been working on a palindrome and it won't support an even number of words. I'm not the best at coding. It supports words like "racecar" or "tacocat", but it won't let me use a word/name like "Hannah". I'm new at this coding stuff so anything…
S.Ngin
  • 21
  • 6
2
votes
1 answer

Dynamic programming algorithm to find palindromes in a directed acyclic graph

The problem is as follows: given a directed acyclic graph, where each node is labeled with a character, find all the longest paths of nodes in the graph that form a palindrome. The initial solution that I thought of was to simply enumerate all the…
2
votes
4 answers

Why do I get correct output for palindromes but no output for regular numbers?

I'm trying to check if a number is a palindrome or not. To do that I'm counting the number of times the kth element is equal to the (n-k)th element. If that number is equal to the length of the string , then it is a palindrome. I do get correct…
Devesh Lohumi
  • 362
  • 2
  • 15
2
votes
1 answer

Time complexity of an algorithm: find length of a longest palindromic substring

I've written a small PHP function to find a length of a longest palindromic substring of a string. To avoid many loops I've used a recursion. The idea behind algorithm is, to loop through an array and for each center (including centers between…
2
votes
5 answers

Longest palindromic substring top down dynamic programming

Here is the algorithm for finding longest palindromic substring given a string s using bottom-up dynamic programming. So the algorithm explores all possible length j substring and checks whether it is a valid palindrome for j in 1 to n. The…
zcadqe
  • 937
  • 2
  • 13
  • 20
2
votes
3 answers

static variable in recursive function in c

I'm writing a program that checks if a number is a palindrome using recursion. I used a static variable to keep the value of the number written backwards and at the end I compared if it was equal to the original number. It works fine when testing…
Titan3
  • 106
  • 10