You are given a string ‘s’. Your task is to tell whether string is beautiful or not.A beautiful string is a string in which String starts with ‘a’ or ‘A’ and middle element is either ‘m’ or ‘M’ and last element is ‘z’or ‘Z’
You are given a string ‘s’. Your task is to tell whether string is
beautiful or not.A beautiful string is a string in which String starts
with ‘a’ or ‘A’ and middle element is either ‘m’ or ‘M’ and last element
is ‘z’or ‘Z’
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 = (data);
var b = a.length
var c= Math.round(b/2)
if((a[0]=="a"||a[0]=="A")&&(a[c-1]=="m"||a[c-1]=="M")&&(a[b-1]=="z"||a[b-1]=="Z"))
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 = (data);
var b = a.length
var c= Math.round(b/2)
if((a[0]=="a"||a[0]=="A")&&(a[c-1]=="m"||a[c-1]=="M")&&(a[b-1]=="z"||a[b-1]=="Z"))
console.log(1)
else
console.log(0)
});
Comments
Post a Comment