We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Implementation
  4. Breaking the Records
  5. Discussions

Breaking the Records

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 1848 Discussions, By:

recency

Please Login in order to post a comment

  • asdrubalyarod34
    10 hours ago+ 0 comments

    c++

    int contMin=0;
    int contMax=0;
    int mayor=scores[0], menor=scores[0];
    vector<int> nuevoV;
    
        for(int i=0;i<scores.size();i++){
        
            if(scores[i]>mayor){
                mayor=scores[i];
                contMax++;
                
            }
            if(scores[i]<menor){
                menor=scores[i];
                contMin++;
            }
        
        }
    
         nuevoV.push_back(contMax);
         nuevoV.push_back(contMin);
    
    return nuevoV;
    
    0|
    Permalink
  • awaistauqir1
    3 days ago+ 0 comments

    My js solution

    function breakingRecords(scores) {
        // Write your code here
        let max = 0, min = 0;
        let lowest = scores[0],highest = scores[0];
        for (let i = 0; i < scores.length; i++) {
            if(scores[i] > highest){
                highest = scores[i];
                max++;
                
            }  
            if(scores[i] < lowest){
                lowest = scores[i];
                min++;
            }  
        }
        return [max, min];
    }
    
    0|
    Permalink
  • saiharshithkasu1
    3 days ago+ 0 comments

    my java solution

    List<Integer> b = new ArrayList<>();
        int hscore=scores.get(0),lscore=scores.get(0);
        int hcount=0,lcount=0;
        for(int i=1;i<scores.size();i++){
        if(scores.get(i)>hscore){
            hscore=scores.get(i);
            if(hscore>=scores.get(i)){
                hcount++;
            }
            else{
                continue;
            }
        }
        if(scores.get(i)<lscore){
            lscore=scores.get(i);
            if(lscore<=scores.get(i)){
                lcount++;
            }
            else{
                continue;
            }
        }
        }
        b.add(hcount);
        b.add(lcount);
                return b;
        }
    }
    
    0|
    Permalink
  • smumarhashmi
    3 days ago+ 0 comments

    This is the code in JavaScript ** **All the suggestions are highly appreciated

    function breakingRecords(scores) {
        let turn = 0;
        let minScore = 0;
        let maxScore = 0;
        let highRec = 0;
        let lowRec = 0;
        let result = [];
        for(let i of scores){
            if(turn == 0){
                minScore = i;
                maxScore = i;
                turn += 1;
                // console.log('turn increased by 1 and setted initial scores',i);
            }
            else{
                if(i>maxScore){
                    // console.log(`the maxScore was ${maxScore} and i is ${i} `)
                    maxScore = i;
                    highRec += 1;
                    // console.log(`the maxScore is ${maxScore} setted equal to i  ${i} `)
                }
                else if(i<minScore){
                  // console.log(`the minScore was ${minScore} and i is ${i} `)
                    minScore = i;
                    lowRec += 1;
                  // console.log(`the minScore is setted to ${minScore} equal to i  ${i} `)
                }
            }
        }
        result.push(highRec);
        result.push(lowRec);
        return result
    
    }
    
    0|
    Permalink
  • adilkhatik24
    4 days ago+ 0 comments

    def breakingRecords(scores): # Write your code here max1=[] min1=[] cmax=cmin=0 h=[] l=[] for i in scores: max1.append(i) min1.append(i) h.append(max(max1)) l.append(min(min1)) for i in range(len(h)-1): if h[i]!=h[i+1]: cmax+=1

        if l[i]!=l[i+1]:
            cmin+=1
    return cmax,cmin
    
    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy