#include<bits/stdc++.h>
using namespace std;
void repx(string s,int str,int nxt)
{
int n=s.length();
if(nxt==n)
{
return;
}
if(s[str]==‘x’)
{
while(s[nxt]==‘x’)
{
nxt++;
}
swap(s[str],s[nxt]);
}
repx(s,str+1,str);
}
int main()
{
string s;
cin>>s;
repx(s,0,0);
cout<<s;
}
I have taken two integers str and nxt which will represent index of the array if at any point ‘x’ is fount it will increment to see if any if next index has ‘x’ if yes it will increment again if not it will swap with str element with base case until nxt==n.