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.

-4
votes
0answers
28 views

palindrome string using stack and queue [closed]

Picure of the question Here are the question for my assignment: "QUESTIONS: Create a program to performs the following tasks one-by-one in sequence order. Your program must use the stack and ...
-1
votes
1answer
26 views

Return function does not return in palindrome checker with javascript

I am working on palindrome checkers in Free Code camp. In manual test with console.log, all test pass. But FCC dont accept it, and i redo it in if conditions with return true, seems nothing is ...
-1
votes
3answers
35 views

How to check for palindrome, ignoring special characters and case?

I have a palindrome: 'Mr. Owl ate my metal worm' Below is my code giving me output as False. def is_palindrome(value): lower = value.lower() return value == value[::-1] print(is_palindrome(...
0
votes
3answers
50 views

Palindrome in java

Here what I tried sample input is "aabaa" eg: in if condition val[0] = a[4] if it is equal i stored it in counter variable if it is half of the length it original string it is palindrome if ...
-4
votes
0answers
40 views

I want to reduce time complexity of this code, any idea?

def palindromeSubStrs(self, Str): res=set() count=0 for i in range(len(Str)): for j in range(i + 1, len(Str) + 1): if Str[i:j] in res: continue ...
-1
votes
0answers
39 views

How do you create a palindrome generator as a recursive function?

Inverting a string is easy: def invert(text): if text == "": return text else: return invert(text[1:]) + text[0] I'm trying to create a recursive function that also ...
1
vote
2answers
50 views

Longest Palindrome Edge Case due to String / StringBuilder Equality

This code doesn't work for the test case: aacabdkacaa, but it works for babad or cbbd. I wrote a print statement to debug and realized the code thinks that the strings aacakdbacaa and aacabdkacaa are ...
1
vote
3answers
47 views

Palindrome checker using user input and while loop in bash

I'm trying to make a bash script that checks if a word is a palindrome for my homework assignment, but I can't get my while loop to work properly. The script should keep running and asking for a ...
1
vote
1answer
124 views

Hackerrank - Solving Palindrom Index Solution

Problem: Given a string of lower case letters in the range ascii[a-z], identify the index of character to be removed to change the string into a palindrome. If the string cannot be converted to ...
0
votes
1answer
34 views

How to compare between elements of two arrays? [duplicate]

I am trying to check if a number is palindrome or not, I took the numbers in a string then put them into an array of numbers, and I was able to reverse this array of numbers into a new array. Now I ...
-1
votes
2answers
86 views

Find minimum length of substring to rearrange for palindromic string [closed]

There is a string s. What is minimum length of substring to rearrange for making string s palindrome. Example: Input: abbaabbca Output: 4 I can rearrange substring from index 4 to 7 (abbc), and get ...
0
votes
1answer
46 views

variable ‘count’ set but not used in c

This is my palindrome code in c: #include <stdio.h> #include <stdlib.h> char toUpperCase(char c) { if (c > 'Z') { c -= 32; } return c; } int isPalindrom(char word[...
0
votes
0answers
40 views

Determination of the length of one of the longest palindromes in a string

I have to implement a function that determines the length of one of the longest palindromes in a string. The strings consist only of numbers and letters. When testing palindromes, upper and lower case ...
-1
votes
1answer
63 views

codewars Longest Palindrome kata: function returns -Infinity error

Task: https://www.codewars.com/kata/54bb6f887e5a80180900046b/train/javascript My solution: function longestPalindrome(str){ var Palindromes = [], reverser = i => i.split("").reverse()....
0
votes
0answers
21 views

Which queue-derived data type could facilitate the fastest algorithm to check if an string is a palindrome?

I am wondering if using Deque data structure implemented by ArrayDeque could offer better performance in terms of time complexity compared to the queue implemented by an array or a linked list? As far ...

15 30 50 per page
1
2 3 4 5
107