Move x to last of the string

My solution passes all test cases. but is it the right way?

#include
using namespace std;

void movex(char* inp, int i){
if(inp[i]==’\0’){
return;
}
if(inp[i]!=‘x’) cout<<inp[i];
movex(inp,i+1);
if(inp[i]==‘x’)cout<<inp[i];
}
int main() {
char ch[1005];
cin>>ch;
movex(ch,0);
return 0;
}

this is correct and good approach
in this approach you are using backtracking ans solving the problem
instead of shifting or using extra space

Keep Learning :grinning: