#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
for(int i=0;i<(((int)s.length())-1);i++) // look here
{
if(s[i]==s[i+1])
{
s.erase(i,2);
i=-1;
}
}
if(s.length()==0)
cout<<"Empty String\n";
else
{
cout<<s<<"\n";
}
}
it gives me the right output.
But when I use this for-loop I was facing an issue. please explain what's the difference between these two. thanks in advance
for(int i=0;i<s.length()-1;i++) // look here