Skip to content

Commit 467ac17

Browse files
committed
[level 2] Title: 최댓값과 최솟값, Time: 0.09 ms, Memory: 43.8 MB -BaekjoonHub
1 parent 23ebc9c commit 467ac17

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# [level 2] 최댓값과 최솟값 - 12939
2+
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12939)
4+
5+
### 성능 요약
6+
7+
메모리: 43.8 MB, 시간: 0.09 ms
8+
9+
### 구분
10+
11+
코딩테스트 연습 > 연습문제
12+
13+
### 채점결과
14+
15+
정확성: 100.0<br/>합계: 100.0 / 100.0
16+
17+
### 제출 일자
18+
19+
2026년 06월 16일 17:45:20
20+
21+
### 문제 설명
22+
23+
<p>문자열 s에는 공백으로 구분된 숫자들이 저장되어 있습니다. str에 나타나는 숫자 중 최소값과 최대값을 찾아 이를 "(최소값) (최대값)"형태의 문자열을 반환하는 함수, solution을 완성하세요.<br>
24+
예를들어 s가 "1 2 3 4"라면 "1 4"를 리턴하고, "-1 -2 -3 -4"라면 "-4 -1"을 리턴하면 됩니다.</p>
25+
26+
<h5>제한 조건</h5>
27+
28+
<ul>
29+
<li>s에는 둘 이상의 정수가 공백으로 구분되어 있습니다.</li>
30+
</ul>
31+
32+
<h5>입출력 예</h5>
33+
<table class="table">
34+
<thead><tr>
35+
<th>s</th>
36+
<th style="text-align: center">return</th>
37+
</tr>
38+
</thead>
39+
<tbody><tr>
40+
<td>"1 2 3 4"</td>
41+
<td style="text-align: center">"1 4"</td>
42+
</tr>
43+
<tr>
44+
<td>"-1 -2 -3 -4"</td>
45+
<td style="text-align: center">"-4 -1"</td>
46+
</tr>
47+
<tr>
48+
<td>"-1 -1"</td>
49+
<td style="text-align: center">"-1 -1"</td>
50+
</tr>
51+
</tbody>
52+
</table>
53+
54+
> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function solution(s) {
2+
const arr = s.split(" ");
3+
const min = Math.min(...arr);
4+
const max = Math.max(...arr);
5+
6+
return `${min} ${max}`;
7+
}

0 commit comments

Comments
 (0)