What is the time and space complexity of my code?

#include
using namespace std;
void move_all_x(char input[],int i)
{
if(input[i]==’\0’)
{
cout<<input;
return;
}
if(input[i]==‘x’)
{
int k=i;
for(;input[k+1]!=’\0’;k++)
{
input[k]=input[k+1];
}
input[k]=‘x’;
input[k+1]=’\0’;
}
move_all_x(input,i+1);
}
int main()
{
char ch[1000];
cin>>ch;
move_all_x(ch,0);
return 0;
}

Time Complexity: O(n^2)
Space Complexity: O(n)

space complexity should not be o(n) due to call stack?

yes yes space complexity is O(n)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.