Weak test cases in case of multiple spaces between two words


#1

If there is multiple spaces between two words and even if I am not handling that case all test cases are passing.

Example :
Input : " This is String"
Ouput: “String is This” which is wrong, but the correct output should be “String is This”.


#2

With improvements in their solution
string Solution::solve(string A) {
string x="",y="";
for(int i=0;i<A.size();i++){
if(A[i]==’ ‘&&y!=""){
x = " “+y+x;
y=”";
}
else{
if(A[i]!=’ ')
y+=A[i];
}
}
x=y+x;
return x;
}