Zoos

PHOTO EMBED

Sat Apr 30 2022 00:27:20 GMT+0000 (Coordinated Universal Time)

Saved by @GreenMark #javascript

//Zoos

// 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(check(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 check(data) {

    const n=data.length;
    let x = 0;
    let y = 0;

    for (let i=0; i<n; i++) {
        if (data[i]=="z") {
            x++ ;
        } else {
            if (data[i]=="o") {
                y++;
            } 
        }
    }

    if (2 * x == y) {
        return "Yes";
    } else { return "No";}


}
content_copyCOPY

Problem You are required to enter a word that consists of and that denote the number of Zs and Os respectively. The input word is considered similar to word zoo if . Determine if the entered word is similar to word zoo. For example, words such as zzoooo and zzzoooooo are similar to word zoo but not the words such as zzooo and zzzooooo. Input format First line: A word that starts with several Zs and continues by several Os. Note: The maximum length of this word must be . Output format Print Yes if the input word can be considered as the string zoo otherwise, print No. Sample Input zzzoooooo Sample Output Yes

https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/is-zoo-f6f309e7/