Radha newly learnt about palindromic strings.A palindromic string is a string which is same when read from left to right and also from right to left.Help her in implementing the logic
Radha newly learnt about palindromic
strings.A palindromic string is a string which is same when read from
left to right and also from right to left.Help her in implementing the
logic
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var a = String(data[0]);
var b=a.split("")
var c=b.length
var count=0
for(i=0;i<b.length;i++)
{if(a[i]===a[c-(i+1)])
count++
}
if(count==c)
console.log(1)
else
console.log(0)
});
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var a = String(data[0]);
var b=a.split("")
var c=b.length
var count=0
for(i=0;i<b.length;i++)
{if(a[i]===a[c-(i+1)])
count++
}
if(count==c)
console.log(1)
else
console.log(0)
});
Comments
Post a Comment