Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [palindrome]

Any sequence of units (typically letters or numbers) that are read the same way forward or backward.

Filter by
Sorted by
Tagged with
-3
votes
0answers
42 views

Longest Palindromic Substr [on hold]

I am looking for review on the algo, and want to know the runtime complexity. Variable naming is garbage, I know. This is a Python function to find the longest palindromic substring using a ...
1
vote
0answers
42 views

How do I optimize memoization in order to find longest palindromic substring?

I want to find the longest palindromic substring using dynamic programming in Python3. The strings can be as large as this string. I have seen other questions on this problem that successfully solve ...
1
vote
0answers
47 views

longest palindrome code in C# takes time out on LeetCode

I like to request a review of the code below, which is my attempt at answering the question at here on LeetCode site. The code passes 43 tests, but it times out on the next one. I copied and ran the ...
0
votes
3answers
61 views

Basic Palindrome check comparing chars

I've seen variations of this assignment where you reverse a string to match it to the original to find out if it is a palindrome, but this version I made only iterates through half of the string ...
6
votes
3answers
458 views

CTCI Chapter 1 : Palindrome Permutation

Below is my code for the problem 1.4 in CTCI. I would like a review of my code and if my approach to the problem is correct. Problem Statement: Palindrome Permutation: Given a string, write a ...
3
votes
1answer
66 views

Project Euler - Problem No.4 - Largest palindrome product

according to the problem: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made ...
4
votes
3answers
2k views

Palindrome test

This is some code that determines if a string of characters is a palindrome or not. My professor says that there is a performance issue with the program, but I can't quite put my finger on it. Can ...
3
votes
2answers
245 views

Calculate the largest palindromic number from the product of two 6-digit numbers (100000 to 999999)

Are there any efficient ways to solve this problem, for example using bitwise operator? ...
3
votes
1answer
297 views

Palindromic partitions solution

Task Find the smallest number of cuts required to break a string into a set of valid palindromes. For example: ababbbabbababa becomes a|babbbab|b|ababa (cuts = 3) partytrapb becomes partytrap|b (...
1
vote
2answers
53 views

Palindrome Pairs

The task is taken from leetcode Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] ...
2
votes
0answers
142 views

Longest Palindrome Substring: Where is the dynamic programming? [closed]

In this LeetCode problem, Longest Palindromic Substring, it is listed under Dynamic Programming for Google interview preparation. My understanding of dynamic programming is roughly "recursion + ...
4
votes
4answers
168 views

Largest Palindrome Product - Project Euler #4

This is my code for Project Euler Problem #4 The question: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. ...
0
votes
0answers
57 views

Split string into as few substrings as possible such that each substring is a palindrome

The task Given a string, split it into as few strings as possible such that each string is a palindrome. For example, given the input string racecarannakayak, return ["racecar", "anna", "...
0
votes
1answer
61 views

Why does my function think that “uiouioiu”is a plaindrome? [closed]

I was reading Introduction to Computation and Programming using Python and there in an exercise, we had to write a function which would tell us if a given word is a palindrome or not, recursively. ...
4
votes
3answers
757 views

Determine whether an integer is a palindrome

The task Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: ...
4
votes
1answer
97 views

Return whether a string is a palindrome if you can delete at most k elements

The task: Given a string which we can delete at most k, return whether you can make a palindrome. For example, given 'waterrfetawx' and a k of 2, you could delete f and x to get '...
11
votes
5answers
833 views

Easy to read palindrome checker

I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is \$\mathcal{O}(n)\$ but I'm not too sure ...
4
votes
2answers
314 views

Longest Palindromic Substring better approach

I have encountered to this question and applied a brute force algorithm off top of my head and couldn't find a better optimized solution. I was hoping I could get some insight to implement a better ...
1
vote
1answer
69 views

Check if given integer is a palindrome

This code checks if the given integer is a palindrome. If it is, prints given integer is a palindrome else, not a palindrome: ...
1
vote
4answers
181 views

Read a palindrome of unknown length

I have a task to write the function: int read_palindrome(); // input comes from stdin which will read one line from standard input and returns 1 if the line is a ...
2
votes
1answer
121 views

Find palindromes in circular rotated string

I'm trying to tackle a programming challenge to determine how many palindromes exist in a given string that is being rotated character by character. My solution works, but it's too slow, and I'm ...
10
votes
2answers
204 views

Determining if a string can be permuted to a palindrome

I am going through Elements of Programming Interview by Aziz, Lee and Prakash one of the questions is how to determine if a string can be permuted to a palindrome. For example ...
2
votes
0answers
176 views

Longest Palindromic Substring challenge

My code is a mix-up between dynamic programming with the HashMap and brute force with the way I reach out the results and substring. I don't know how to optimize my ...
4
votes
2answers
77 views

Solve Project Euler #4 in PHP

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit ...
3
votes
4answers
3k views

Find longest Palindrome substring

I am preparing for technical interview and I found this question on geeksforgeeks, but I did not understand their solution. So, I have written my own solution. I want to optimize this code. ...
-2
votes
1answer
73 views

Find the first palindrome larger than the given number

Question Input number of test cases. Input each test case and output its next palindrome number. Link: https://www.spoj.com/problems/PALIN/ Language Used: C++14 (gcc 6.3) My code ...
1
vote
1answer
47 views

A program that checks for Palindromness

Yes, I made it up. This program checks if an entered string is a palindrome or not by assigning a char variable the characters ...
2
votes
2answers
113 views

Find a palindromic string in C

This program tests whether a string is a palindrome or not. Can there be any improvements or shortcuts that can be used in the program. You can give any type of string as input. The program finds does ...
10
votes
5answers
437 views

Circles of numbers

I have a function: ...
7
votes
3answers
1k views

The Next Palindromic number

I have incremented an integer in the function nextpalin() and converted it into a std::string for finding whether it's a ...
0
votes
1answer
136 views

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

I think this is a good solution to finding the largest numeric palindrome that can be formed from the product of two 3-digit numbers... But it seems like there are some improvements that we could make ...
7
votes
1answer
2k views

Check if a given linked list is palindrome

I am solving interview questions from here. Problem :Given a singly linked list, determine if its a palindrome. Return 1 or 0 denoting if its a palindrome or not, respectively. Notes:Expected ...
4
votes
2answers
947 views

Next palindromic number

I wrote a function that takes a number and finds the next palindromic number. Time complexity is currently O(n2), which is really bad. How could one make this function more efficient? ...
15
votes
5answers
5k views

Palindrome checking function

I recently did a little task for fun that required me to create a class to determine if a word is a palindrome or not. I know this is quite simple, but I'd be interested to know if a real developer (I'...
0
votes
1answer
40 views
1
vote
2answers
4k views

Count palindrome substrings

Given a string S, count and return the number of substrings of S that are palindromes. Single length substrings are also palindromes. We just have to count the substring that are palindrome. ...
0
votes
2answers
2k views

Palindrome algorithm

This code could be better? This is the algorithm: Compare the 1st character to the last character Compare the 2nd character to the second last character and so on Stop when the middle of the ...
2
votes
2answers
2k views

Largest palindrome made from the product of 3-digit numbers

I am given a task to write a program to find the largest palindrome made from the product of two 3-digit numbers. How can I improve this code? ...
4
votes
2answers
629 views

Finding palindromic strings of even length

Given a string of digits. Find the length of longest substring of even length i.e. 0,2,... which is a palindrome or which can be rearranged to form a palindrome (see example below). Here is my code: ...
6
votes
2answers
1k views

Counting the number of continuous palindromic substrings

Given a string of lowercase ASCII characters, find all distinct continuous palindromic sub-strings of it. Here is my code: ...
4
votes
1answer
675 views

C++ check if Palindrome

Just did this simple application to check whether a string is a palindrome or not ...
1
vote
0answers
462 views

Python palindrome function; is it possible to write it without using string conversion?

I hope this question is okay to ask on Code Review; this is a little function I wrote in Python 2.7.12 that checks if a number is a palindrome. It works fine but I'd like to know if there is a purely ...
2
votes
1answer
64 views

Performing the Lychrel algorithm in Rust

A Lychrel number is a natural number that cannot form a palindrome through the iterative process of repeatedly reversing its digits and adding the resulting numbers. In the code below I'm trying to ...
3
votes
2answers
1k views

Find a substring which could be rearranged into a palindrome

Problem statement: To find maximum length substring in an input string which could be arranged into a palindrome, only even length palindromes are expected. Input is one line String which ...
12
votes
10answers
6k views

Tests for palindromes in C and C++

A question I've been asked on interactive phone screens is to code a test to determine whether a string is a palindrome or not. I am providing two examples here: one in C and one in C++. They both ...
1
vote
0answers
99 views

C# Project Euler #4: Program that finds Largest palindrome product

So I made a code to improve my programming skills and it works just fine, but it looks chaotic for me. Is there is a better and more efficient way to do it? If you have any ideas/tips I would love to ...
7
votes
4answers
4k views

Find palindromic substrings as efficiently as possible

I've written a function to calculate all the distinct substrings of a given string, that are palindromes. The string is passed as the argument to the function. For example, the string abba is a ...
3
votes
1answer
772 views

Valid Alphanumeric Palindrome

Valid Alphanumeric Palindrome Problem (from Leetcode) Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, ...
3
votes
1answer
1k views

Palindrome implementations - iterative and recursive

I got asked this palindrome question when the interviewer wants to make sure that my palindrome can check if "Taco! Cat!" is a palindrome. In this example, my palindromes implementation needs to ...
-3
votes
1answer
322 views

My third post about Python 3 palindromes

I'm new to python3, and I tried to test if my palindrome codes work and pass most of the edge cases. so I created the following 2 python files below. When I ran the ...