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.
public static List<Integer> breakingRecords(List<Integer> scores) {
// Write your code here
List<Integer> result = new ArrayList<Integer>(2);
result.add(0);
result.add(0);
int min = scores.get(0);
int max = scores.get(0);
for(int i=0; i<scores.size();i++){
if(scores.get(i)<min){
min = scores.get(i);
result.set(1, result.get(1)+1);
}
if(scores.get(i)>max){
max = scores.get(i);
result.set(0, result.get(0)+1);
}
}
return result;
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Breaking the Records
You are viewing a single comment's thread. Return to all comments →
Simple solution using Java 15
}