1 typedef long long ll; 2 #define _for(i,a,b) for(int i = (a);i < b;i ++) 3 #define _rep(i,a,b) for(int i = (a);i > b;i --) 4 #define INF 0x3f3f3f3f 5 #define pb push_back 6 #define maxn 10000 7 8 class Solution 9 { 10 public: 11 int flag; 12 string ss; 13 bool judge(int st,int len) 14 { 15 _for(i,st,st + len - 1) 16 { 17 if(ss[i] != ss[i+1]) 18 return false; 19 } 20 return true; 21 } 22 string removeDuplicates(string s, int k) 23 { 24 flag = 0; 25 ss = s; 26 while(s.size()!=flag) 27 { 28 flag = s.size(); 29 ss = s; 30 _for(i,0,s.size()) 31 { 32 if(judge(i,k)) 33 { 34 s.erase(i,k); 35 i = -1; 36 ss = s; 37 } 38 } 39 } 40 return s; 41 } 42 };