언젠가는 펼쳐 볼 아카이브
[BOJ] 2562번 - 최댓값 본문
사용언어 : 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}`);
}
'IT > Baekjoon Oline Judge' 카테고리의 다른 글
[BOJ] 10813번 - 공 바꾸기 (0) | 2023.08.16 |
---|---|
[BOJ] 10810번 - 공 넣기 (0) | 2023.08.16 |
[BOJ] 10818번 - 최소, 최대 (0) | 2023.08.16 |
[BOJ] 10807번 - 개수 세기 (0) | 2023.08.16 |
[BOJ] 10951번 - A+B - 4 (0) | 2023.08.16 |