Don't know why this solution failded for case ".x.x.x..x" . Clearly, solution should be 4, but its expected to be 5


#1
int Solution::seats(string A) {
    int found = A.find('x');
    int s=0;
    if(found==std::string::npos) return 0;
    for(int j=found+1;j<A.size();j++){
        if(A[j]=='x'){
           if(j==found+1) {found=j; j=found;}
           else {
               s+=j-found-1;
               found=j;
               j=found;
           }
        }
    }
    return s%10000003;
}

#2

No the answer would be 5 only.

.x.x.x..x Initial

.x.x.xx.. +2
      ^ ^
.x..xxx.. +1
   ^^
...xxxx.. +2
 ^ ^
-------------
 Answer = 5
-------------