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
2 answers

Problems with Palindromes in C

I've written some code in C to try adn find whether or not a number is a Palindrome. The rule is that two 3 digit numbers have to be multiplied together and you have to find the highest palindrome. the answer should be 906609 but my code only gets…
SD1990
  • 808
  • 1
  • 11
  • 29
3
votes
3 answers

Cannot input more than one string in palindrome program

#include #include using namespace std; void isPalindrome(); int main() { char response; isPalindrome(); cout << "Input another string(y/n)?" << endl; cin >> response; response = toupper(response); if…
lvl1_monk
  • 33
  • 3
3
votes
2 answers

Find palindrome python space complexity?

Given the following code in python which checks whether an string of n size is palindromic: def is_palindromic(s): return all(s[i] == s[~i] for i in range(len(s) // 2)) What is the space complexity of this code? Is it O(1) or O(n)? The all…
KaliTheGreat
  • 579
  • 6
  • 17
3
votes
17 answers

Find the largest palindrome made from the product of two 3-digit numbers

package testing.project; public class PalindromeThreeDigits { public static void main(String[] args) { int value = 0; for(int i = 100;i <=999;i++) { for(int j = i;j <=999;j++) { …
arsenal
  • 23,366
  • 85
  • 225
  • 331
3
votes
2 answers

Fastest way to check if a string contains a palindrome substring

I am trying to check if a string contains any substring of length > 1 which is a palindrome. (Note that this is not the same as checking if the whole string is a palindrome.) I was able to write a function that finds even- or odd-length palindrome…
Clock Slave
  • 7,627
  • 15
  • 68
  • 109
3
votes
1 answer

Stuck on how to make this palindrome pairs finding function be less than O(N^2)

Task here is to find palindromes formed by combining pairs of the original word list (so for below, stuff like "callac" and "laccal"). I thought I had an idea of pre-computing all the reversed versions of each word (N). Then for each original word,…
Aaron
  • 2,154
  • 5
  • 29
  • 42
3
votes
4 answers

How to count all the palindromes in a string using recursion?

I have a recursive function that checks if a string is a palindrome, but my assignment asks me to count the number of palindromes in a string (for example kayak has 2). I'm really confused about how I can implement a recursive function that counts…
3
votes
1 answer

How to write a Javascript function to get all palindromic subsequences from string in order?

A subsequence is a group of characters chosen from a list while maintaining their order. For instance, the subsequenes of the string abc are [a, b, c, ab, ac, bc, abc]. Now, I need to write a function to return all the palindromic subsequences from…
Kristada673
  • 3,512
  • 6
  • 39
  • 93
3
votes
2 answers

scala palindrome function with forloop

Would like to know the Scala equivalent of Java palindrome function, writing forloop with multiple variables is tricky in scala class Solution { public boolean isPalindrome(String s) { for (int i = 0, j = s.length() - 1; i < j; i++, j--) { …
shiv455
  • 7,384
  • 19
  • 54
  • 93
3
votes
2 answers

Adding reversed previous number to achieve palindrome in python

Accept a number as an input and check whether the given number is palindrome or not if it is a palindrome number print the number on the screen if it is not a palindrome number reverse that number and add it to previous number repeat this until will…
venkat0107
  • 240
  • 1
  • 12
3
votes
3 answers

Leetcode Valid Palindrome Question Problem Debugging

I'm struggling to understand what's wrong with my code for this Leetcode problem. Problem: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Right now, I am passing 108/476 cases, and I am…
3
votes
2 answers

Palindrome program for emu8086 in assembly language

I'm trying to complete my last lab exercise for my microprocessors course and could really use some help with this. The job is to fill the commented empty lines with my own code. Here's the task: **Task 2. Test if the string is a palindrome**…
Erik
  • 33
  • 5
3
votes
1 answer

Find longest palindrome substring of a piece of DNA

I have to make a function that prints the longest palindrome substring of a piece of DNA. I already wrote a function that checks whether a piece of DNA is a palindrome itself. See the function below. def make_complement_strand(DNA): …
Lynn
  • 35
  • 6
3
votes
3 answers

error on using uppercase in palindrome prog in java

package Assignments; import java.util.Scanner; public class Assignment1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); int i=0,j=str.length()-1,count=0; while(i!=j) { …
3
votes
2 answers

Checking if string has only one character mismatch of palindrome in java

I have to write a boolean function that takes a string and check if a string is a palindrome or not in java. Here is my code static boolean isPalindrome(String input) { int i = 0; last = input.length() - 1; while (i < last) { …
Sara
  • 113
  • 1
  • 1
  • 8