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.

Filter by
Sorted by
Tagged with
-2 votes
0 answers
33 views

How to make palindrome [closed]

How do i make a palindrome in python i tried making palindrome in python but it didn't work. A palindrome is a word, number, phrase, or other sequence of symbols that reads the same backwards as ...
Komalpreet Grewal's user avatar
1 vote
2 answers
72 views

Some test cases failing while trying to implement palindrome of a string in C without using built in functions

I was given this problem as a lab assignment and I've only got 3 days left to submit it. The program is to print 1 for a palindrome and -1 for not palindrome. I could've easily done this using strrev()...
SpaciousCoder78's user avatar
-7 votes
0 answers
33 views

Why is the leetcode palindrome problem failing with this code? Below code is failing at **x = 1000021**. Output should be False but its giving True [duplicate]

problem - https://leetcode.com/problems/palindrome-number/description/ class Solution: def isPalindrome(self, x: int) -> bool: if (x<0): return False elif (0<=x&...
Yash's user avatar
  • 315
-1 votes
1 answer
41 views

write a python program to check if a sting is a palindrome [closed]

palindrome is a word, sentence, verse or even number that reads the same backward or forward. write the program in def() function. Also answer must be returned. I tried doing it with normal input and ...
Ankita Maji's user avatar
1 vote
6 answers
180 views

Palindromic number in C

So lets say we have this program in C that checks if a number is palindromic or not, WITHOUT the use of any array at all(so dont respond with any answer that uses an array) #include <stdio.h> #...
konxanth's user avatar
-2 votes
2 answers
112 views

C program that checks if a number is palindromic

I wrote this C program which compiles just great, but when I enter an input it never stops running and when I force stop it, it says "floating point exception (core dumped)". It is basically ...
konxanth's user avatar
-4 votes
0 answers
78 views

It doesn't show the "empty" message [duplicate]

This program checks if the string is a palindrome. First it takes the int N as input then reads N strings. It shows "yes" if it palindrome, "no" if it isn't and it supposed to show ...
Paul Mar.'s user avatar
1 vote
3 answers
153 views

How to reverse an array's values and input them into another array?

I am trying to create a code in which the person inputs a number N between 1 to 100, so they can input N amount of words-phrases up to 20 characters. The program then finds out if the said word or ...
IaMaPsYcHo's user avatar
1 vote
2 answers
65 views

How to make Palindrome Program? [duplicate]

I tried to reverse the inputed String, and output "This is a Palindrome." when the input is equal to its reverse. The reverse part is correct, but it keeps saying it is not equal, even ...
JAKE's user avatar
  • 13
0 votes
2 answers
56 views

How to "bring back" whitespaces after using a line of code that ignores them? (Palindrome assignment)

I'm struggling to figure out exactly how I'd be able to place spaces back into the output of my code. For example, if the palindrome is "race car," I need to first ignore the spaces in that ...
Rob's user avatar
  • 3
0 votes
1 answer
50 views

Why the original Linked List is getting lost after passing as a argument in reverse function

When I am trying to reverse the original Linked List, it gets lost after the function call. Why is it so? Node *reverse(Node *head) { Node *prevNode = NULL, *currNode = head; while (currNode !=...
Bharat Sharma's user avatar
0 votes
1 answer
45 views

UndefinedBehaviorSanitizer: undefined-behavior [duplicate]

I am trying to solve palindrome number problem using object oriented cpp. I faced an occurrence of an strange error in my code which say "signed integer overflow: -1734809184 * 10 cannot be ...
Pratick's user avatar
  • 19
0 votes
1 answer
148 views

I need to write a turbo prolog program, which will remove all palindromes from the list

I need to do a turbo prolog program that removes all palindromes (includes crossed palindromes like 1 2 1 3 1) from the list. I tried to do a program using the following algorithm: For ex: 1 2 1 3 1 4 ...
Seryozhka's user avatar
1 vote
3 answers
72 views

Checking if linked list is a palindrome

public boolean palindromLinkedList() { //find size Node temp = head; int size=0; while(temp != null){ size++; temp=temp.next; } //find while loop iteration ...
Rishiksai Santhosh's user avatar
-1 votes
3 answers
80 views

how to write palindrome number in java code

public static void palindromeNo(int n){ // reverse number find first of all for find the number is palindrome or not // reverse int temp = n; int ...
SHAGUFA ANJUM 's user avatar
0 votes
0 answers
160 views

Palindrome checker in MIPS/ASSEMBLY

I'm working on some code for class, it is written in MIPS assembly for PLPTool 5.2. The program should receive a string of characters via the UART, check if this string is a palindrome, and then use a ...
Jonathan Alvaro's user avatar
-1 votes
1 answer
33 views

Missing element to complete a palindrome by python

I don't know how to do it USING PYTHON. But the program must print the missing letter in the given palindrome. INPUT should be: input_string="abcdeedba" OUTPUT should be: c I guess we can ...
Praga desh's user avatar
0 votes
1 answer
233 views

codesignal remove palindrome prefixes and return string

You are given a string s. Consider the following algorithm applied to this string: Take all the prefixes of the string, and choose the longest palindrome between them. If this chosen prefix contains ...
Tate's user avatar
  • 1
2 votes
1 answer
93 views

Compile-time palindrome check

What should I do to check whether an integer array is palindrome (e.g. 1 3 10 3 1 is palindrome) in compile time? A possible framework could be: template <int...> class IntArray; template <...
27rabbit's user avatar
0 votes
0 answers
32 views

(Pallindrome checker) [LEETCODE problem] I know I'm commiting some minor mistake but i don't know what it is

class Solution { public: bool isPalindrome(string s) { getline(cin,s); bool answer; vector<int>l; vector<int>r; ...
Mrigraj Yadav's user avatar
-2 votes
2 answers
84 views

Why does my for loop always return 'False'?

Here is the given task: Write a function that receives two words, in string format, s1 and s2. It should return True, if s1 and s2 are palindromes, and False otherwise. I started by converting the ...
thumpy's user avatar
  • 21
-1 votes
1 answer
74 views

Count palindrome number that have total digits is divisible by 10

How to count many palindrome number that have total digits is divisible by 10 from L to R (1 <= L <= R <= 10^12) in 0.5s? My idea: generate palindrome number then count. But it is TLE. Here ...
Firrew_MinhQuan's user avatar
1 vote
3 answers
154 views

Why do I get heap buffer overflow in leetcode?

I was trying to solve a problem for returning the longest palindrome in a string. I first copy the string in reverse order, and then try to find the longest substring. Here is the code I wrote: char *...
DhruvS's user avatar
  • 15
-2 votes
3 answers
95 views

Unable to prove palindrome number for "11" in C programming

leet code palindrome problem, i am trying to prove test case " 11 " is a palindrome but i am unable to , despite other test cases passsing correctly bool isPalindrome(int x){ if(x<0) ...
Shafeeq Ahamed's user avatar
0 votes
2 answers
58 views

How can i return the original phrase after determining if its a palindrome?

class Node: def __init__(self, data, link): self.data = data self.link = link def __str__(self): return str(self.data) class Deque: def __init__(self): ...
DMOSnd's user avatar
  • 25
1 vote
2 answers
58 views

Recursion method on finding whether a given string is a palindrome or not

def palindrome(w): if len(w)==0 or len(w)==1: p = 'yes' return p else: if w[0]==w[-1]: del w[0] del w[-1] palindrome(w) else:...
Hiruni Sathsarani's user avatar
0 votes
2 answers
62 views

JavaScript palindrome checker. What is wrong with this code? The input "almostoma" should have given a false output, but my code gives a true output

It works just fine with other palindromes (e.g "Able was I saw Elba.", "A man, a plan, a canal. Panama."), but fails with "almostoma". function palindrome(str) { ...
Patrick's user avatar
  • 19
0 votes
5 answers
367 views

c recursive function to check if a string is palindrome

I am doing a project in C programming language and one of the tasks require me to recursively check if a string is a palindrome. I wrote some code but I don't get correct output. Here are some rules ...
Abdurrahman Kabir's user avatar
1 vote
1 answer
52 views

Skip spaces in string during loop, Assembly palindrome

I'm trying to do a palindrome checker program and I'm stuck in skipping spaces in string. It works with single words but not with sentences. I've tried to add a skip_space1 and skip_space2 but it ...
wojst's user avatar
  • 11
0 votes
1 answer
19 views

Tracking user's insertion mark within two different texts simultaneously, excluding certain signs

My problem is a logical one rather than one pertaining to code directly. I'm having problems planning out what should happen exactly step by step. (I'm writing a program to create palindromic pairs of ...
David Soael's user avatar
0 votes
1 answer
17 views

def Palindrome() doesn't return Palyndrom

I face the problem and don't know the way to fix it. Code works good but anyway it reponds that 'message' isn't palyndrom even if it's really palindrom. But when I revise it with one word only it goes....
Dmitry's user avatar
  • 13
1 vote
1 answer
79 views

Can anyone please tell me why my code is not working properly

I have written a piece of code to determine whether a linked list is a palindrome, but it's not working properly. Can you please explain what's wrong with my code? Node* reverse(Node* head) { if (...
Aditya Choudhary's user avatar
0 votes
2 answers
59 views

Recursion seems to iterate one last time how can I fix this code?

I am attempting to check if a string is a palindrome or not( reads the same forwards and backwards ) I am having trouble understanding why the output is throwing the error that the variable has not ...
Max's user avatar
  • 13
0 votes
1 answer
78 views

I am getting AddressSanitizer: heap-buffer-overflow error for longest palindrome substring

The problem I tried to solve is the longest palindrome substring problem on LeetCode. When I run my code on DEVC++ it works perfectly fine, but when I try to run on leetcode it gives this "...
bleckemr's user avatar
1 vote
1 answer
7 views

Error: char cannot be converted to string

Help me understand and fix the error please. I've commented the line in which error occurs. import java.util.*; public class Main { public static void main(String[] args) { Scanner sc= new Scanner(...
Hritikesh S Shendre's user avatar
-1 votes
4 answers
111 views

Python - Leetcode 9. Palindrome Number - formatting my solution into the leetcode format

Beginner here. I did "Leetcode 9. Palindrone Number" and think I figured out the solution, but as a beginner I am not familiar with some basic Python formats. Leetcode Problem = Given an ...
Light_528's user avatar
0 votes
1 answer
230 views

how to check whether a string is palindrome or not by using recursive function

I want to write a program that takes a string from input ( the size of the string is less than 100000) and then checks if it is palindrome or not. the spaces and punctuation marks should not be ...
Fateme's user avatar
  • 41
0 votes
2 answers
79 views

sum of numeric palindromes

I'm stuck on a problem test. The prompt is: A palindrome is a word, number, phrase, or another sequence of characters which reads the same backward as forward, such as madam, racecar, or the number ...
alainsanguinetti's user avatar
-3 votes
1 answer
78 views

How can I optimize this Python program to find palindromes?

I made this Python program that generates multi-word palindromes from a given list of words.(A palindrome being a sequence of characters that reads the same forwards and backwards, disregarding spaces,...
FlingYourself's user avatar
0 votes
1 answer
70 views

Two simultaneous returns in python recursive function

How can I implement the following code in Python? class Solution: def p(self, s:str): if len(s)<= 1: return True elif s[0] != s[-1]: return False ...
Subhrajit Samanta's user avatar
0 votes
0 answers
26 views

wrong output while making palindrome checker in assembly language

I am trying to make a palindrome checker but it keeps saying its not a palindrome when it is. I got the string and loaded it into a stack (as a part of my school assignment) and so now my program ...
kate's user avatar
  • 3
-4 votes
1 answer
75 views

Palindrome Checker Assistance [closed]

I need help with my Palindrome Checker using the provided instructions :( If someone could show and explain the missing code, it would be a big help! Palindrome Checker
Silly Piggy's user avatar
2 votes
1 answer
172 views

VBA Palindrome function

I created the following function to check wether a given word is a palindrome and send back true or false. However, the function return #NAME! . Hereby the code: Option explicit Public Function ...
Bobo31's user avatar
  • 31
2 votes
1 answer
120 views

what is the time complexity of an algorithm that recursively checks if a string is a palindrome?

I have solved the problem using this algorithm and have calculated that the total number of recursive calls is n/2 since we always pass a substring of the original string with 2 less characters. The ...
WilliamG's user avatar
0 votes
0 answers
35 views

Find the String length between first and last palindrome in the array

I need to find Strings length between first and last palindrome in the array. ` public static String firstPalindrome(String[] words) { int count = 0; int result1 = 0; for (int i = 0; i ...
Slavi Donchev's user avatar
0 votes
4 answers
125 views

C++ Palindrome Unique solution , giving error

class Solution { public: bool isPalindrome(int x) { if(x < 0) { return false; } if(x < 10){ return true; } int s = 0; ...
Anuj Garg's user avatar
0 votes
0 answers
42 views

'int' object has no attribute '__getitem__'. Problem in line 2

x = input() reverseuserinput = x[::-1] if x == reverseuserinput: print("true") else: print("false") My code works in VS but when I submit it on leetcode it doesnt work ...
0zyu's user avatar
  • 1
-3 votes
2 answers
106 views

why else statement cannot run in loop for C?

Here is the code and when I run it, the statements show that the loop cannot jump into else function. I am not sure which part of code is wrong. bool isPalindrome(char A[], int n) { int flag = 1; ...
xuefei zhang's user avatar
0 votes
0 answers
98 views

Finding the longest palindrome in a single-dimensional array, using recursion, without loops, in Java

The details of the problem are as the same as described in title. The time complexity and space complexity can be ignored in the specific question. I did not stumble upon questions involving ...
Rami Mamadov's user avatar

1
2 3 4 5
36