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.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Algorithms
  3. Implementation
  4. Breaking the Records
  5. Discussions

Breaking the Records

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 1174 Discussions, By:

votes

Please Login in order to post a comment

  • lahouari 4 years ago+ 0 comments

    My java submission:

    static int[] getRecord(int[] s)
    {
        int highest, lowest;
        highest = lowest = s[0];
        
        int[] result = new int[2];
        
        for (int s_i = 1; s_i < s.length; s_i++)
        {
            if (s[s_i] > highest)
            {
                highest = s[s_i];
                ++result[0];
            }
            else if (s[s_i] < lowest)
            {
                lowest = s[s_i];
                ++result[1];
            }
        }
        
        return result;
    }
    
    35|
    Permalink
  • marinskiy 2 years ago+ 0 comments

    Here is Python 3 solution from my HackerrankPractice repository:

    def breaking_records(score):
        min = max = score[0]
        min_count = max_count = 0
        for i in score[1:]:
            if i > max:
                max_count += 1
                max = i
            if i < min:
                min_count += 1
                min = i
        return max_count, min_count
    
    
    n = int(input())
    score = list(map(int, input().split()))
    print(*breaking_records(score))
    

    Feel free to ask if you have any questions :)

    28|
    Permalink
  • itsbaldeep 2 years ago+ 0 comments

    JavaScript

    // Preparing variables
    let [ hi, lo ] = [ scores[0], scores[0] ];
    let [ max, min ] = [ 0, 0 ];
    
    // Calculating
    for (let i = 1; i < scores.length; i++) {
    	if (scores[i] > hi) { hi = scores[i]; max++; }
    	if (scores[i] < lo) { lo = scores[i]; min++; }
    }
    
    //Returning
    return [ max, min ];
    
    9|
    Permalink
  • abhiarora1137 2 years ago+ 0 comments

    My code is working properly in editor, but i'm getting error here , "result.join() is not a function". Code language Javascript.

    6|
    Permalink
  • gulshankumarpal 10 months ago+ 0 comments
    int* breakingRecords(int scores_count, int* scores, int* result_count) {
        int* a=(int*)malloc(2*sizeof(int));
    int highcount=0,lowcount=0,max,min;
    max=scores[0];
    min=scores[0];
    for(int i=1;i<scores_count;i++)
    {   if(scores[i]>max)
            {max=scores[i];
            highcount+=1;}
        if(scores[i]<min)
            {min=scores[i];
            lowcount+=1;}
    }
    a[0]=highcount;
    a[1]=lowcount;
    *result_count=2;
    return a;
    }
    
    4|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature