palindrome

Solutions on MaxInterview for palindrome by the best coders in the world

showing results for - "palindrome"
Henry
10 Sep 2020
1function isPalindrome(sometext) {
2  var replace = /[.,'!?\- \"]/g; //regex for what chars to ignore when determining if palindrome
3  var text = sometext.replace(replace, '').toUpperCase(); //remove toUpperCase() for case-sensitive
4  for (var i = 0; i < Math.floor(text.length/2) - 1; i++) {
5    if(text.charAt(i) == text.charAt(text.length - 1 - i)) {
6      continue;
7    } else {
8      return false;
9    }
10  }
11  return true;
12}
13//EDIT: found this on https://medium.com/@jeanpan/javascript-splice-slice-split-745b1c1c05d2
14//, it is much more elegant:
15function isPalindrome(str) {
16  return str === str.split('').reverse().join(''); 
17}
18//you can still add the regex and toUpperCase() if you don't want case sensitive
Mira
27 May 2017
1// devuelve cierto si la subcadena que hay entre las posiciones inicio y fin es palindromo.
2  bool esPalindromo(char cad[], int inicio, int fin){
3    bool pal = false;
4
5    if(inicio == fin){
6      pal = true;
7    }else{
8      if(cad[inicio] == cad[fin]){
9        pal = esPalindromo(cad, inicio + 1, fin - 1);
10      }
11    }
12
13    return pal;
14  }
Roberta
18 Nov 2019
1//made by Kashish Vaid the great.
2// Palindrome programme using for loop the easiest prgm
3#include <stdio.h>
4int main() {
5    int n, rev = 0, remainder, num;
6    printf("Enter an integer: ");
7    scanf("%d", &n);
8    num = n;
9
10    // reversed integer is stored in rev
11  for(num = n ; n!=0 ; n/=10)
12{
13    remainder = n%10;
14    rev = rev*10 + remainder;
15}
16// if else shortcuts
17    ( (rev == num) ? printf("%d is a palindrome.", num) : printf("%d is not a palindrome.", num) );
18    return 0;
19}
20//made by Kashish Vaid the great.
Tommaso
27 Nov 2020
1#include<iostream>
2#include<string>
3#include<algorithm>
4bool IsPalindrome_true_false(const std::string& );
5
6int main ()
7{
8    
9    std::cout<<"Please enter a string:\t";
10    std::string str;
11    getline(std::cin, str);
12    
13    // convert the string from uppercase to lowercase 
14    int i = 0;
15    while(str[i])
16    {
17        if(str[i] == std::toupper(str[i]) && std::isalpha(str[i]) == 1024)
18        str[i]+= 32;
19        ++i;
20    }
21    // looping while string is empty 
22    while(str.empty())
23    {
24        std::cout<<"\nPlease enter a string your string is empty:\t";
25        if(!str.empty())
26        std::string str;
27        getline(std::cin, str);
28    }
29    
30    std::cout<<"\n"<<std::boolalpha<<IsPalindrome_true_false(str)<<std::endl;
31    std::cout<<std::endl;
32
33    return 0;
34}
35
36// check if string is a palindrome and return true or false 
37bool IsPalindrome_true_false(const std::string& str)
38{
39
40    int i = 0;                
41    int j = str.length() - 1; 
42
43    while(i <= j )
44    {   
45        
46        if(std::isalpha(str[i]) == 0){
47            ++i;
48            continue;
49        }else if(std::isalpha(str[j]) == 0){
50            --j;
51            continue;
52        }   
53        if(str[i] != str[j]){
54        
55           return false;
56        }
57        ++i;
58        --j;
59    }  
60    return true;
61}
62
63
64
65
Rafael
25 Jul 2018
1function isPalindrome(text) {
2  return [...text].reverse().join('') === text;
3}
4
5isPalindrome = text => {
6	return [...text].reverse().join('') === text;
7}
8
9isPalindrome = text => [...text].reverse().join('') === text;
Alberto
20 Feb 2019
1#include <stdio.h>
2int main() {
3    int n, reversedN = 0, remainder, originalN;
4    printf("Enter an integer: ");
5    scanf("%d", &n);
6    originalN = n;
7
8    // reversed integer is stored in reversedN
9    while (n != 0) {
10        remainder = n % 10;
11        reversedN = reversedN * 10 + remainder;
12        n /= 10;
13    }
14
15    // palindrome if orignalN and reversedN are equal
16    if (originalN == reversedN)
17        printf("%d is a palindrome.", originalN);
18    else
19        printf("%d is not a palindrome.", originalN);
20
21    return 0;
22}
23
24
queries leading to this page
a palindrome ispalindrome number in c programmingsentence with palindrome wordsis palindrome algorithmpalindrome string program in cpalindrome number prog in cgiven string palindrome or not in cmake it a palindromepalindrome en algorithmewhat is a palindrome numberpalindrome salam iwhart is palindromepalindrome program in cpalindrome 2b palindromethe palindromepalindrome significado espa c3 b1olpalindrome check in cmeaning of palindromewhaqt is a palindromepalindrome mi palindrome ipalindrome meanspalindrome 2b 2ba palindrome examplecan you make a palindromepalindrome words10 alphabet pallendromecheck if a number is a palindrome in cwhat i a palindromepalindrom numbersc program check for palindrome numberpalindrome 27palindrome functionccheck if given character array is palindrome in cis a a palindromepalindrome examplepalindrome 8086palindrome algorithmedefinition of palindromepalindrome number definitionf palindromepalindrome recursionpalindromes examplepalindrome cpalindrome valuespalindrome problempalindrome codepalindrome number 2awhats is a palindromepalindrome in 8086palindrome in c using functionpalindrom codeun palindromewhat is palindrome number palindrome schemeshow me palindromesracecar word backwardswhat is palindromedefine palindromeis 27a 27 palindromewhat words are spelled the same backwardspalindrome numcerlong words that are palindromespalindrome of a number cpalindrome onlinepalindrome sentecethat are palindromewhat does palindrome meanis 27a 27 a palindromeque es un palindromopalindrome nameis 26 a palindromepalindrome in cpalyndromeis palindromenumber is palindrome r not in c palindromefacts about palindromepalindrome inwhat is a palindrome 3fpalindrome indexvalid palindromepalindrome nombrepalindrome sentencenot palindrome wordspalindrome meaning computerpalindrome program palindrome number in cspecial palindrome palindrome englishpalindrome checkpalindrome ordewhat defines a palindromechecking palindromewhats a palindromepalindrome series in cpalindrome functionexample of palindromepalindrome is a numberwhat is a palindromepalindromes numbersnumber is a palindromenumber palindromepalindrome exemplechecking palindrome in cpalindrome number pexample of palindrome wordsis palindrome codec program to check a number is palindrome or notpalindrome defineis this a palindromepronounce palindromepalindrome meainglong palindromepalindrome sentence examplepalindrom 28 29 28 29meaning of palindrome numberpalindrome one expressionstack palindrome in cpalindrome strings examplesa palindrome meaningpalindrome algorithmpalindrome an exampleexample of a palindromeint palindrome in cque es pal c3 adndromopalindrome number in palindrome numbers 3fpalindrome palindrome of a numberpalindromes lista palindromelong palindrome sentencepalindrome nittinfind palindromespalindrome in c functionpalindrome in c with pointerpalindrome dictionarypalindrome createwhat is the palindromeexamples of palindrome wordspalindrome in c programforwards and backwards wordspalindrome esopepalindromes definitiondate palindrome significato esotericopalindrome number meaningpalindrome ammapalindrome string in c1 define palindrome palindrome app dopalindorme string namepalindrome worduse of palindromeinteger palindrome in cpalindrome numberspalindrome nofamous palindromelist of palindromespalindrome defintiionword palindrpmeses palindromowhat is this start at the bottom and read each line backward 2c saying all the important characters 3fpalindrome5 palindrome palindrome number palindrome characterwhat is the meaning of palindrome numberpalindrome in array in cpalindrome solutionwhat is the meaning of palindromewhat is the opposite of a palindromewhats palindromewhat is palindrome palindrom definitionpalindrome algorithm numberpalindrome number program in cthe meaning of palindromeword that 27s the same backwardspalin drome sentencepalindrome patternun palindrome 29 palindrom sentencewhat is it called when a word is the same backwardsc program for longest palindrome in a stringis a palindromevalid palindrome ipalindrome fucntionnumber is palindromelength of palindrome palindromipalindrome 2csymentrypalindrome exampleswhat is a palindromepalindrome examplepalindrome numbercreate palindromepalindrome characterpalindrome typepalindrom number display in cexamples of palindrome palindrome wordpalendrom textfeatures of a palindromepalindrome in schemewhat is the palindrom wordspalindrome atcodrephrase palindromewhat palindrome meanslarge palindrome wordspalindromo que esword forward and backward readwhat is the name of a word that is spelled the same forwards and backwardswhat are palindrome numbersapalindrome exemplespalindrome meanwhat 27s a palindrome numberwhta is palindromehow to get palindromnumber is palindrome or notcool palindrome sentencesdefinition of a palindromeexemple palindromepalindrome of numberc program palindromepalindrome integerword palindromespalindrome examples wordswhat are the palindrome numbersis single character palindrome 3fpalindrome app 2ccheck palindromepalindrome defpalindromic wordsstoria palindromeis palindrome possible 3fpalindrome mathwhat 27s palindromea program in c to check a palindrome phrasec program for palindrome stringpalindrome definitionnumber is palindrome palindrome number what are palindrome numberswhat do you mean by palindromepalindrome number in c 2b 2bpalindrome meaningdo palindromenumber of palindromes based on length n in cbioternary same words from both sidespalindrome defintionproperties of a palindromepalindrome