Breaking the Records

  • + 0 comments

    Simple solution using Java 15

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

    }