Mars Exploration

  • + 0 comments

    Here is my c++ solution

    int marsExploration(string s) { int sz = s.size(); string strSos("SOS");

    int no_sos = sz/ 3;
    
    for(int i = 0; i < no_sos-1; i++)
        strSos.append("SOS");
    
    int cnt = 0;
    for( int i = 0; i < sz; i++)
    {
        if( strSos[i] != s[i] )
            cnt++;
    }
    return cnt;
    

    }