Skip to content

Instantly share code, notes, and snippets.

@kharioki
Created January 2, 2019 12:50
Show Gist options
  • Save kharioki/bd3b6ebb76f0bbf3ff851280243abc54 to your computer and use it in GitHub Desktop.
Save kharioki/bd3b6ebb76f0bbf3ff851280243abc54 to your computer and use it in GitHub Desktop.
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});
process.stdin.on('end', _ => {
inputString = inputString.replace(/\s*$/, '')
.split('\n')
.map(str => str.replace(/\s*$/, ''));
main();
});
function readLine() {
return inputString[currentLine++];
}
// Complete the birthdayCakeCandles function below.
function birthdayCakeCandles(ar) {
const max = Math.max(...ar);
return ar.filter(x => x === max).length;
}
function main() {
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
const arCount = parseInt(readLine(), 10);
const ar = readLine().split(' ').map(arTemp => parseInt(arTemp, 10));
let result = birthdayCakeCandles(ar);
ws.write(result + "\n");
ws.end();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment