You are viewing a single comment's thread. Return to all comments →
public static int marsExploration(String str) { int count = 0; for(int i=1; i<=str.length();i++) { char ch = str.charAt(i-1); int loc = i%3; if((loc == 1 && ch != 'S') || (loc == 2 && ch != 'O') || (loc == 0 && ch != 'S')) count++; } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Mars Exploration
You are viewing a single comment's thread. Return to all comments →