블로그를 이전하였습니다. 2023년 11월부터 https://bluemiv.github.io/에서 블로그를 운영하려고 합니다. 앞으로 해당 블로그의 댓글은 읽지 못할 수 도 있으니 양해바랍니다.
반응형
문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다
1. 문제
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
2. 풀이
전체 코드
<javascript />
const solution = (input) => {
const nums = input.split(' ').map((s) => +s.split('').reverse().join(''));
return Math.max(...nums);
};
require('readline')
.createInterface(process.stdin, process.stdout)
.on('line', (input) => console.log(solution(input)))
.on('close', () => process.exit(0));
상세 풀이
배열에 reverse()
함수를 사용하면, 배열의 원소를 역순으로 재정렬해준다. 이를 활용하면 쉽게 풀 수 있는 간단한 문제다.
전체 코드
https://github.com/bluemiv/Algorithm/blob/master/baekjoon/nodejs/src/ex02/ex2908.js
GitHub - bluemiv/Algorithm: 알고리즘 풀이
알고리즘 풀이. Contribute to bluemiv/Algorithm development by creating an account on GitHub.
github.com
2.1. 풀이 결과
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
3. 관련 글
2022.07.21 - [Algorithm/Beakjoon] - jest 단위테스트를 이용하여 백준 알고리즘 문제 편하게 풀기
jest 단위테스트를 이용하여 백준 알고리즘 문제 편하게 풀기
쉬운 문제는 웹 사이트에서 풀어도 되지만, 복잡한 문제는 여러 경우의 케이스에 대해서 실행해보는 경우가 생긴다. 백준에서는 다른 알고리즘 문제 사이트와 다르게 웹에서 실행해볼수가 없어
memostack.tistory.com
반응형
'Algorithm > Beakjoon' 카테고리의 다른 글
백준 11654번 / 아스키 코드 (nodejs 알고리즘 풀이) (2) | 2022.09.02 |
---|---|
백준 1316번 / 그룹 단어 체커 (nodejs 알고리즘 풀이) (0) | 2022.09.01 |
백준 1152번 / 단어의 개수 (nodejs 알고리즘 풀이) (0) | 2022.08.30 |
백준 2675번 / 문자열 반복 (nodejs 알고리즘 풀이) (0) | 2022.08.29 |
백준 10818번 / 최소, 최대 (nodejs 알고리즘 풀이) (0) | 2022.08.27 |