You are viewing a single comment's thread. Return to all comments →
C++ O(n)
int marsExploration(string s) { int res=0; for(int i=0;i<s.length();i+=3) { if(s[i]!='S' || s[i+1]!='O' || s[i+2]!='S' ) { if(s[i]!='S') { res++; } if(s[i+1]!='O') { res++; } if(s[i+2]!='S') { res++; } } } return res; }
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 →
C++ O(n)