Problem Info
My Work
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cout<<":["<<x<<"XE]"<<endl;
#define debug2(x,y) cout<<":["<<x<<" "<<y<<"XE]"<<endl;
#define _ ios_base::sync_with_stdio(false);
#define mod 1000000007
#define mod2 998244353
int main()
{_
ll t=1,ca=1;
//cin>>t;
while(t--){
freopen("censor.in","r",stdin);
freopen("censor.out","w",stdout);
string s,tt,s2;
cin>>s>>tt;
ll n=tt.size();
if(n==1){
for(int i=0;i<s.size();i++){
if(s[i]!=tt[0])cout<<s[i];
}
continue;
}
for(int i=0;i<s.size();i++){
if(i>=n-1&&s.substr(i-n+1,n)==tt){
for(int j=1;j<=n;j++){
s.erase(i,1);
i--;
}
}
}
cout<<s<<endl;
}
}
I have iterated the string and if found the last T string length substring matched with string T then erased that substring and continued this way…
Question
This solution is giving TLE, I have downloaded test data but failed to debug because of big test data and I don’t see any reason to TLE of my solution. Can anyone please help why my solution is TLE or give a small test data that cause TLE?