Mars Exploration

  • + 0 comments
    public static int changedLetters(char s1, char O, char s2){
            int count=0;
            if (s1!='S') {
                count++;
            }
            if (s2!='S') {
                count++;
            }
            if (O!='O') {
                count++;
            }
            return count;
        }
        public static int marsExploration(String s) {
        // Write your code here
        int output=0;
        for (int i = 0; i < s.length(); i+=3) {
            int count=0;
            count=changedLetters(s.charAt(i+0),s.charAt(i+1),s.charAt(i+2));
            output=output+count;
            System.err.println("count="+count+"output="+output);
        }
        return output;
    
        }