irborrero
7/21/2019 - 6:59 PM

Comparing Characters

// Complete the alternatingCharacters function below.
    static int alternatingCharacters(String s) {

        int deleted = 0;
        for(int i=0; i<s.length()-1;i++){
            if(s.charAt(i) == s.charAt(i+1)) deleted++; //THIS IS CASE SENSITIVE
        }

        return deleted;

    }