Fraudulent Activity Notifications

  • + 1 comment

    i did this solution: but only 5/8. what is wrong?

    public static int activityNotifications(List expenditure, int d) { int counter=0; int sum=0;

        for(int i=0;i<d;i++){
            sum+=expenditure.get(i);
        }
        for(int i=d; i<expenditure.size();i++){
            double avg=(double)sum/d;
            if(expenditure.get(i)>=2*avg){
                counter++;
            }
    
            sum-=expenditure.get(i-d);
            sum+=expenditure.get(i);
    
        }
       return counter;
    }