You are viewing a single comment's thread. Return to all comments →
Here my java code :
public static List breakingRecords(List scores) { if (scores.isEmpty() || scores.size() == 1) { return Arrays.asList(new Integer[]{0, 0}); } Integer max = scores.get(0); Integer min = scores.get(0); Integer highestScore = 0; Integer lowestScore = 0; for (int i = 1; i < scores.size(); i++) { if (max < scores.get(i)) { max = scores.get(i); highestScore++; } if (min > scores.get(i)) { min = scores.get(i); lowestScore++; } } return Arrays.asList(new Integer[]{highestScore, lowestScore}); }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Breaking the Records
You are viewing a single comment's thread. Return to all comments →
Here my java code :
public static List breakingRecords(List scores) { if (scores.isEmpty() || scores.size() == 1) { return Arrays.asList(new Integer[]{0, 0}); } Integer max = scores.get(0); Integer min = scores.get(0); Integer highestScore = 0; Integer lowestScore = 0; for (int i = 1; i < scores.size(); i++) { if (max < scores.get(i)) { max = scores.get(i); highestScore++; } if (min > scores.get(i)) { min = scores.get(i); lowestScore++; } } return Arrays.asList(new Integer[]{highestScore, lowestScore}); }