Mars Exploration

  • + 0 comments
    //java
        public static int marsExploration(String s) {
        // Write your code here
        int changedLetters = 0;
        char[] chars = s.toCharArray();
        for(int i=0; i<s.length(); i+=3) {
            if(chars[i] != 'S')
                changedLetters++;
            if(chars[i+1] !='O')
                changedLetters++;
            if(chars[i+2] !='S')
                changedLetters++;
        }
        return changedLetters;
    }