test case 2 showing run error
Move all x at end
Jatin, i think you approach is little bit wrong, you can basically take a function having two parameters as , movexatend(str," ");
and the function definition is as follows, :
void movexatend(string str,string osf)
{
char ch=str[0];
if(str.length()==0)
{
cout<<osf;
return;
}
string ros=str.substr(1);
if(ch!=‘x’)
{
movexatend(ros,osf+ch);
}
else
{
movexatend(ros,osf);
cout<<ch;
}
I hope you understood this approach,
Okay mam…But my logic was just showing run error in one case and all other test cases passed…can you please tell What’s wrong in my code.
Your code is not producing correct output for the test case :
abbxbbxee
As it is the only test case, where the string is ending with character other than ‘x’, as all other cases that were passed by your code contains ‘x’ at the end of input string, thus I would recommend you to change the code…