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

integar array palindrome checker

i made this program to make a function to check if integar array is palindrome or not.it is always giving output that it is not a palidrome on every input. can you plz help me out? code: #include using namespace std; void …
-1
votes
1 answer

Palindrome words check function : python 3

The is_palindrome function checks if a string is a palindrome. A palindrome is a string that can be equally read from left to right or right to left, omitting blank spaces, and ignoring capitalization. Examples of palindromes are words like kayak…
KMB90
  • 63
  • 2
  • 3
-1
votes
6 answers

Optimal brute force solution for finding longest palindromic substring

This is my current approach: def isPalindrome(s): if (s[::-1] == s): return True return False def solve(s): l = len(s) ans = "" for i in range(l): subStr = s[i] for j in range(i + 1, l): …
Duong Pham
  • 11
  • 3
-1
votes
1 answer

Why recursive function is producing uncognisable output if not using return at the end of the recursion?[CODE BELOW]

I just wrote a function in C++ of checking whether a string is a palindrome. bool isPal(string str, int s, int e) //s= starting index and e= (size of string -1) { if(s==e || s>e) return true; if(str[s]!=str[e]) return…
ayush7ad6
  • 31
  • 4
-1
votes
2 answers

Python code for palindrome which auto corrects

I was given a task in python to write a code which contains a function which receives an input number from the user and if it isn't a palindrome - it finds the nearest (lower) palindrome number, for example: findprevpalindrom(100) to…
helpme
  • 39
  • 1
-1
votes
5 answers

Am getting IndexError: string index out of range -Python

def is_palindrome(x, pos_index, neg_index): if x[pos_index] == x[neg_index]: print("") else: return False pos_index += 1 neg_index -= 1 is_palindrome(x, pos_index, neg_index) print(is_palindrome("racecar", 0,…
-1
votes
1 answer

How can i make my Programm accept Palindrom with capital letter or space between?

import java.util.Scanner; public class palindrome { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String word = sc.next(); String org_word = word; word =…
NonoTheGR
  • 1
  • 1
-1
votes
4 answers

The Palindromes, Python, Problems

I am a newbie python coder learning for fun. I am wondering why this program has difficulty outputting the correct output. I believe the problem lies with the very end of the program "if list == inverselist:". I always get an output telling me the…
-1
votes
1 answer

iterations of characters are required to make wekqqhibrmxz a palindrome string

Make it a palindrome How many iterations of characters are required to make wekqqhibrmxz a palindrome string? Consider alphabets to be a circular list, A comes next to Z 1- 131 2- 114 3- 25 4- 15 Can anybody guide the way to go to solve this?
-1
votes
1 answer

Data structure and algorithm(C++)

A palindrome is a phrase that reads the same forward and backward (examples: ‘racecar’, ‘radar’, ‘noon’, or ‘rats live on no evil star’). By extension we call every string a palindrome that reads the same from left to right and from right to left.…
Rimon
  • 9
-1
votes
1 answer

Python check Palindrome

I was solving the problem at Codesignal and saw one of the solutions that check palindrome like this. def checkPalindrome(inputString): return inputString == inputString[::-1] How is that working? Please explain what is going on here.
Capz
  • 9
-1
votes
1 answer

Palindrome Linked-list

Here's my code. The concept is to traverse the whole linkedlist by taking two pointers fast and slow ,once slow is at the middle ,will reverse the list and compare it with the second half which is fast. /** * Definition for singly-linked list. *…
-1
votes
1 answer

Finding the longest Palindrome in a string and returning the longest single word in Javascript

I writing a method to find the longest palindrome in a sentence of words. So far I have used the for loop to do this but its not returning the correct word. function findLongestPalindrome(sentence) { let wordArray = sentence.split(" "); let…
andy86
  • 75
  • 1
  • 6
-1
votes
4 answers

Reversing a string without using the REVERSE function in Common LISP

I'm creating a program that can determine if a string is palindromic or not for a final project. However, I'm not allowed to use the REVERSE function. Here's my attempt so far with the REVERSE function. (defun palindrome(x) (if (string= x…
Sieg
  • 31
  • 5
-1
votes
1 answer

Make the string lexicographically smallest and non palindromic by replacing exactly one character

Given a palindromic string palindrome, replace exactly one character by any lowercase English letter so that the string becomes the lexicographically smallest possible string that isn't a palindrome. After doing so, return the final string. If…
curiousD
  • 27
  • 6