• + 0 comments

    I am not getting why it is showing wrong answer for some test cases

    class stck{ public: int sum; vector* ptr; };

    int equalStacks(vector h1, vector h2, vector h3) { stck* s1,*s2,*s3; s1=new stck; s2=new stck; s3=new stck; long long sm=0; for(int i=0;isum=sm; s1->ptr=&h1; sm=0; for(int i=0;isum=sm; s2->ptr=&h2; sm=0; for(int i=0;isum=sm; s3->ptr=&h3; int i,j,k; i=0,j=0,k=0;

    while(1){
    
        if(s1->sum>=s2->sum and s1->sum>s3->sum){
             s1->sum=s1->sum-(*s1->ptr)[i++];
         }
        else if(s2->sum>=s1->sum and s2->sum>s3->sum){
             s2->sum=s2->sum-(*s2->ptr)[j++];
            }
        else if(s3->sum>=s1->sum and s3->sum>s2->sum){
             s3->sum=s3->sum-(*s3->ptr)[k++];
    
            }
        else{break;}
        }
    return s1->sum;
    

    }