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.
function breakingRecords(scores) {
const minSCR = [scores[0]];
const maxSCR = [scores[0]];
let min = 0;
let max = 0;
for (let i = 1; i < scores.length; i++) {
if (minSCR.every((min) => scores[i] < min)) {minSCR.push(scores[i]),min++; }
else if (maxSCR.every((max) => scores[i] > max)) {
maxSCR.push(scores[i]), max++;
}
}
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 →
javascript
function breakingRecords(scores) { const minSCR = [scores[0]]; const maxSCR = [scores[0]];
let min = 0; let max = 0; for (let i = 1; i < scores.length; i++) { if (minSCR.every((min) => scores[i] < min)) {minSCR.push(scores[i]),min++; } else if (maxSCR.every((max) => scores[i] > max)) { maxSCR.push(sco
res[i]), max++; } }