Expected output and my output are both same but still giving WA ( -_- )


#1

vector Solution::prettyJSON(string A) {
vector res;
int n = A.size();
string s;
int id=0; int i =0;
while(i<n){

    if(A[i]=='{' || A[i]=='['){ 
        
        string a (id,'\t');
        res.push_back(a+s); s.clear();
        res.push_back(a+A[i]); a.clear();
    
        id++;
    }
    else if(A[i]==',')
    {
        string a1 (id,'\t');
        res.push_back(a1+s+A[i]); a1.clear();
        s.clear();
    }
    else if(A[i]=='}' || A[i]==']'){
        string a2 (id,'\t');
        res.push_back(a2+s); a2.clear();
        id--; string a3 (id,'\t');
        res.push_back(a3+A[i]); a3.clear();
        s.clear();
    }
    else{
        s+= A[i];
    }
    i++;
    
}
return res;

}