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

Adding char from string to stack

I am trying to add the chars from a string in a textbox into my Stack, here is my code so far: String s = txtString.getText(); Stack myStack = new LinkedStack(); for (int i = 1; i <= s.length(); i++) { while(i<=s.length()) { …
Peerkon
  • 33
  • 1
  • 2
  • 5
2
votes
2 answers

How to discard all characters other than a-z && A-Z && 0-9 in user input to find possible palindrome

What does program solve: Find palindrome from user input. What issue to tweak: How to make code accept sentence like Rise to vote sir! as Palindrome if we disregard punctuation and blank spaces. If you read it backwards it will be the same! Things…
2
votes
2 answers

How do I create a palindrome checker?

Here is the problem. https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/palindrome-checker My solution was function palindrome(str) {{ let regex =…
Photons
  • 129
  • 3
2
votes
1 answer

Why I am getting an error "Output Limit Exceeded" in Javascript?

I am trying to solve a problem of LinkedList on leetcode in javascript language but out of 86 test cases 74 cases are passed but at 75 I am getting an error Output Limit Exceeded. Problem: Given the head of a singly linked list, return true if it is…
Harsh Mishra
  • 862
  • 3
  • 15
  • 29
2
votes
1 answer

prefixes and palindromes recursion problem so close to working, what is going wrong here? multiple test cases returning null

For some reason, my solution is returning null instead of the value that is stored in 's'. Instructions and code are below: You are given a string s. Consider the following algorithm applied to this string: Take all the prefixes of the string, and…
2
votes
2 answers

similar code logic, two different answers

why does the output of these two functions give different outputs when the logic or idea is the same and they are working with the same string? def solution(inputString): a = "" b = a[::-1] if a == b: return True else: …
fusion_97
  • 31
  • 2
2
votes
3 answers

segmentation fault, c programm

I had to write a program in c as a homework assignment. The program checks if the inputed string is a palindrome. Unfortunately I am getting a segmentation fault error when executing my program. According to my knowledge segmentation fault means I…
2
votes
2 answers

How can I apply to functions to a list in haskell?

I'm trying to write a function that checks whether or not a given list is a palindrome. However, I can't figure out how to apply to functions to a given input. My Code looks like this: isPalindrome :: [a] -> Bool isPalindrome x | head x == last x…
Rosarosa
  • 51
  • 6
2
votes
0 answers

Minimum number of deletions to make a string palindrome

I have a string consisting zeros and ones and I need to know how many deletions from the beginning I need to do in order to make a string a palindrome. I wrote a function to check if the string is palindrome (and iterate over each element) and it…
Ignos
  • 21
  • 2
2
votes
1 answer

read a local file in javascript and output certain lines from it

I am tasked with a little coding challenge that I can't seem to work out. Its meant to be done in javascript, a language I have touched in years... Basically the task is to read a local file , which has sentences on each line. Some of the sentences…
sparks
  • 49
  • 5
2
votes
4 answers

Palindrome mystery: Why an array of size 3 ends up being printed with 5 elements?

#include #include using namespace std; int main(){ char a[] = "abc"; char b[2]; for(int i = 0,k = 2;i < 3;i++,k--){ b[k] = a[i]; cout << i << " " << k << endl; } if(strcmp(a,b) == 0){ …
Grimnack
  • 29
  • 1
  • 5
2
votes
1 answer

longest palindromic substring using lcs?

I was solving this longest palindromic substring problem on leetcode and I followed the dynamic programming approach by creating one n*n boolean table(which I guess is also the standard solution to this) and successfully solved it but I was just…
2
votes
2 answers

Why do I get undefined? (JS)

I'm writing a code in order to know if a word is a Palindrome. I think my code is correct but I get undefined on "newStr". Like the console tells me that : console.log(newStr) // undefinedracerar I don't understand why and I bet that why I get…
user12986587
2
votes
1 answer

Optimum solution for splitting a string into three palindromes with earliest cuts

I was asked this question in an interview: Given a string (1<=|s|<=10^5), check if it is possible to partition it into three palindromes. If there are multiple answers possible, output the one where the cuts are made the earliest. If no answer is…
Nikhil_10
  • 133
  • 3
  • 10
2
votes
1 answer

Finding all the Palindromes in int array C

It might seem like long but I over explained it. So I have my problem is not necessarily finding the palindromes it is just the finding the length of the palindrome I can't figure out and my code doesn't work for single digit palindromes (yes we…
hohenpaid
  • 99
  • 9