Why getting memory level exceeded


#1

Comment body goint Solution::candy(vector &A) {

int size=A.size();
vector<int> B(size,1);

for(int i=0;i<size-1;i++)
{
    if(A[i]>A[i+1])
    {
       if( B[i]<=B[i+1]) B[i]++;
    }
    else if(A[i]==A[i+1])
    {
        B[i+1]=B[i];
    }
    else {
        B[i+1]=B[i]+1;
    }
    
    
}
int sum=0;
for(int i=0;i<size;i++)
{
    sum+=B[i];
}

}
es here.