Breaking Records – Problem Solving Question & Answer

By | November 1, 2018

Problem Statement

Download or view the problem statement here.

Solution

static int[] breakingRecords(int[] scores) {

    int min = scores[0], max = scores[0];
    int minCount = 0, maxCount = 0;

    int len = scores.length;

    for (int i = 0; i < len; i++) {
        if (scores[i] < min) {
            min = scores[i];
            minCount++;
        }
        if (scores[i] > max) {
            max = scores[i];
            maxCount++;
        }
    }
    return new int[]{maxCount, minCount};
}

Leave a Reply

Your email address will not be published.