Sort by

recency

|

2242 Discussions

|

  • + 0 comments

    Java

    	int min = scores.get(0);
            int max = scores.get(0);
            
            int minRecord = 0;
            int maxRecord = 0;
            
            for (int i = 1; i < scores.size(); i++) {
                if (scores.get(i) < min) {
                    min = scores.get(i);
                    minRecord++;
                } else if (scores.get(i) > max) {
                    max = scores.get(i);
                    maxRecord++;
                }
                
            }
                
            return Arrays.asList(maxRecord, minRecord);
    
  • + 0 comments

    Java Solution

    public static List<Integer> breakingRecords(List<Integer> scores) {
    
        int max=scores.get(0),min=scores.get(0),minCount=0,maxCount=0;
        for(int x : scores){
            if(x>max){
                max=x;
                maxCount++;
            }
            if(x<min){
                min=x;
                minCount++;
            }
    
        }   
         List<Integer> resultList = new ArrayList<>();
            resultList.add(maxCount);
            resultList.add(minCount);   
         return resultList;
    
    }
    
  • + 0 comments

    javascript easy solution

    let max=scores[0]

    let count=0
    
    for(let i = 0;i <scores.length;i++)
    {
        if(scores[i] > max){
            max=scores[i]
            count++
        }
    }
    let min=scores[0]
    
    let count1=0
    
    for(let i = 0;i < scores.length;i++){
        if(scores[i] < min){
            min = scores[i]
            count1++
        }
    }
    
    let arr=[]
    arr.push(count)
    arr.push(count1)
    return arr
    

    }
    arr.push(count1) return arr }

  • + 0 comments

    def breakingRecords(scores): # import numpy as np high, low, h_count, l_count = scores[0], scores[0], 0,0

    for i in scores:
        if i < low:
            l_count+=1
            low = i
        elif i > high:
            h_count+=1
            high= i
        else:
            continue
    
    arr = []
    arr.append(h_count)
    arr.append(l_count)
    
    return arr
    
  • + 0 comments

    JAVA Solution

    public static List breakingRecords(List scores) { // Write your code here

        int max = scores.get(0);
        int min = scores.get(0);
        int maxCount = 0;
        int minCount = 0;
    
        for(int i = 1; i<scores.size(); i++){
    
            int currentScore = scores.get(i);
    
            if(currentScore > max){
                max = currentScore;
                maxCount++;
            }else if(min > currentScore){
    
                min = currentScore;
                minCount++;
    
            }
        }
    
        List<Integer> res = new ArrayList<>();
    
        res.add(maxCount);
        res.add(minCount);
    
        return res;
    }