You are viewing a single comment's thread. Return to all comments →
cpp solution without division, simply using an iterator for the comparing string :
int marsExploration(string s) { string sos = "SOS"; int it = 0; int count = 0; for (int i= 0; i < s.length(); i++) { if (s[i] != sos[it]) { count++; } if (it == 2) { it = 0; } else { it++; } } 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 →
cpp solution without division, simply using an iterator for the comparing string :