IT/Baekjoon Oline Judge
[BOJ] 2562번 - 최댓값
개발자희망생고롸파덕
2023. 8. 16. 19:06
사용언어 : javascript - node.js
#제출 코드
const fs = require('fs');
const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
let input = fs
.readFileSync(filePath)
.toString()
.split('\n')
.map((item) => +item);
solution(input);
function solution(numArray) {
let idx = 0;
let max = -1;
for (let i = 0; i < numArray.length; i++) {
if (numArray[i] >= max) {
max = numArray[i];
idx = i+1;
}
}
console.log(`${max}\n${idx}`);
}