Untitled
unknown
plain_text
2 years ago
584 B
2
Indexable
class Solution {
public:
bool check(string &org,string &make){
for(int i=0;i<make.size();i++){
if(make[i]=='*') continue;
else if(make[i]==org[i]) continue;
else return false;
}
return true;
}
int minimumTimeToInitialState(string word, int k) {
string make=word;
int n=word.size();
int op=0;
string dum="";
for(int i=0;i<k;i++) dum+='*';
do{
make=make.substr(k,n-k)+ dum;
op++;
}while(!check(word,make));
return op;
}
};Editor is loading...
Leave a Comment