Please someone check my code. What i am doing wrong?


#1

int Solution::candy(vector &arr) {
int n=arr.size();
long result =0;
if(n==0)
return 0;
vector candies(n);
fill(candies.begin(),candies.end(),1);

for(int i=1;i<n;i++)
    {
        if(arr[i]>arr[i-1]);
            candies[i]=candies[i-1]+1;
    }
    
for(int i=n-2;i>=0;i--)
    {
        if(arr[i]>arr[i+1])
            candies[i]=max(candies[i],candies[i+1]+1);
    }
    
    for(int i=0;i<n;i++)
        result =result+candies[i];

return result;

}