Can anyone help me in optimising


#1

string Solution::solve(string s, int B) {
string p;
for(int i=0;i<s.length();i++){
int k=1,pos=i;
while(s[i]==s[i+1]&&i<s.length()){
k+=1;
i+=1;
}
if(k!=B){
while(pos<=i&&i<s.length()){
p+=s[pos];
pos+=1;
}
}
}
return p;
}