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 2 * x =y.


Determine if the entered word is similar to word zoo.

For example, words such as zzooooand 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.

import java.util.*;

class TestClass {
    public static void main(String args[] ) throws Exception {
        Scanner s = new Scanner(System.in);
        String word = s.nextLine();
        int count1=0;
        int count2=0;
        for(int i=0;i<word.length();i++) {
            char c = word.charAt(i);
            if(c == 'z') {
            if(c == 'o') {
        if(count1*2 == count2) {
        } else {

To solve this problem on HackerEarth click here.

To see more programs like this click here

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *