Palindrome Checker
const palindrome = str = {
str = str.replace(/[\W+|_]/g, '').toLowerCase()
const str1 = str.split('').reverse().join('')
return str1 === str
}
palindrome("My age is 0, 0 si ega ym.");
Palindrome Checker
const palindrome = str = {
str = str.replace(/[\W+|_]/g, '').toLowerCase()
const str1 = str.split('').reverse().join('')
return str1 === str
}
palindrome("My age is 0, 0 si ega ym.");
determine whether integer is a palindrome
public class Solution {
public bool IsPalindrome(int x) {
if(x < 0 || (x % 10 == 0 && x != 0)) {
return false;
}
int revertedNumber = 0;
while(x > revertedNumber) {
revertedNumber = revertedNumber * 10 + x % 10;
x /= 10;
}
return x == revertedNumber || x == revertedNumber/10;
}
}
check a string is palindrome or not
#include <stdio.h>
#include <string.h>
int main()
{
char str[80];
int length;
printf("\nEnter a string to check if it's a palindrome: ");
scanf("%s", str); // string input
length = strlen(str); // finding the string length
int i, j, count;
for (i = 0, j = length - 1, count = 0; i < length; i++, j--)
{
// matching string first character with the string last character
if (str[i] == str[j])
{
count++; // if character match, increasing count by one.
}
}
if (count == length) // if count == length, then the string is a palindrome.
{
printf("'%s' is a palindrome.\n", str);
}
else // otherwise the string is not a palindrome.
{
printf("'%s' is not a palindrome.\n", str);
}
return 0;
}
what is palindrome
function Palindrome(str) {
str = str.replace(/ /g,"").toLowerCase();
var compareStr = str.split("").reverse().join("");
if (compareStr === str) {
return true;
}
else {
return false;
}
}
check palindrome
bool isPlaindrome(string s)
{
int i=0;
int j=s.length()-1;
while(i<j)
{
if(s[i]==s[j])
{i++;
j--;}
else break;
}
if (i==j || i>j) return 1;
else return 0;
}
check if palindrome
function isPalindrome(str) {
str = str.toLowerCase();
return str === str.split("").reverse().join("");
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us