Palindromic String

PHOTO EMBED

Sun May 01 2022 23:24:21 GMT+0000 (Coordinated Universal Time)

Saved by @GreenMark #javascript

//Palindromic String
// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
  
  var data= input.toString().split("\n");
    process.stdout.write(palindrome(data[0]));       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail



// Write your code here
// Sample code to perform I/O:
//Enter your code here
function palindrome(s) {
    
    var len = s.length;
    var midle = Math.floor(len/2);

    for (var i= 0; i<midle; i++) {
        if (s[i] !== s[len-1-i]) return "NO"
    }    
    return "YES";    
}
     

content_copyCOPY

Problem You have been given a String S. You need to find and print whether this string is a palindrome or not. If yes, print "YES" (without quotes), else print "NO" (without quotes). Input Format The first and only line of input contains the String S. The String shall consist of lowercase English alphabets only. Output Format Print the required answer on a single line. Constraints Note String S consists of lowercase English Alphabets only. Sample Input aba Sample Output YES

Problem You have been given a String S. You need to find and print whether this string is a palindrome or not. If yes, print "YES" (without quotes), else print "NO" (without quotes). Input Format The first and only line of input contains the String S. The String shall consist of lowercase English alphabets only. Output Format Print the required answer on a single line. Constraints Note String S consists of lowercase English Alphabets only. Sample Input aba Sample Output YES