Definitely a problem with test case


#1

Okay so, explain what is the problem?

string Solution::solve(string A) {
    string s;
    int count = 0, flag=0, count1 = 0;
    for(int i=A.size()-1; i>=0; i--) {
        count++;
        count1++;
        if(A[i]==' ') {
            flag = 1;
            int x = A.size()-count;
            for(int j=A.size()-count+1; j<=x+count1; j++) {
                s.push_back(A[j]);
                if(j==A.size()) {
                    s.push_back(' ');
                }
            }
            count1 = 0;
        } 
        if(i==0 && flag==1) {
            for(int j=0; j<count1; j++) {
                s.push_back(A[j]);
            }
        }
    }
    if(flag==0) {
        reverse(A.begin(), A.end());
        return A;
    }
    return s;
}

Output:


#2

Exactly bro, same problem with me… can someone please help out? What seems to be the issue here?