Breaking the Records

  • + 0 comments

    Using C++

    vector breakingRecords(vector scores) {

    vector<int> ans;
    int minCount = 0;
    int maxCount = 0;
    int maxi = scores[0];
    int mini = scores[0];
    
    for(int i = 1; i<scores.size(); i++){
    
        if(scores[i] == maxi || scores[i] == mini){
    
        }
    
        else if(maxi > scores[i]){
    
            maxCount++;
            maxi = scores[i];
        }
        else if (mini < scores[i]){
    
            minCount++;
            mini = scores[i];
        }
    }
    
    ans.push_back(minCount);
    ans.push_back(maxCount);
    
    return ans;
    

    }