Skip to content

Commit 2c96af0

Browse files
committed
find min, max
1 parent 20f8e16 commit 2c96af0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

algorism/maxMinNo.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// https://www.acmicpc.net/problem/10818
2+
3+
4+
const getMaxMinNo = (list_total_count, number_list) => {
5+
number_list.sort((a, b) => a - b);
6+
// 오름차순 정렬
7+
// number_list.sort(); // 1, 100, 32, 50 , 70/
8+
// 숫자 요소는 의도한 대로 정렬 x
9+
// number_list.sort((a, b) => {
10+
// return a - b;
11+
// }); // 1, 32, 50, 70, 100
12+
// number_list.sort((a, b) => a - b); // 1, 32, 50, 70, 100
13+
return [number_list[0], number_list[list_total_count - 1]]
14+
}
15+
16+
console.log(getMaxMinNo(5, [20, 10, 35, 30, 7]));

0 commit comments

Comments
 (0)