Untitled

 avatar
unknown
plain_text
a year ago
584 B
0
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;
    }
};
Leave a Comment