Breaking the Records

Maria plays college basketball and wants to go pro. Each season she maintains a record of her play. She tabulates the number of times she breaks her season record for most points and least points in a game. Points scored in the first game establish her record for the season, and she begins counting from there.


public static List<Integer> breakingRecords(List<Integer> scores) {
    // Write your code here
        int min=scores.get(0);
        int cMin=0,cMax=0;
        int max=scores.get(0);
        ArrayList<Integer>res=new ArrayList<>();
        for(int i=1;i<scores.size();i++)
        {
            if(min>scores.get(i))
            {
                min=scores.get(i);
                cMin++;
            }
            
            if(max<scores.get(i))
            {
                max=scores.get(i);
                cMax++;
            }
        }
        
        res.add(cMax);
        res.add(cMin);
        return res;
        

    }