Skip to content

Commit 437e305

Browse files
committed
Remove_smallest_number / 중급
1 parent be9ad9f commit 437e305

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function solution(arr) {
2+
let minNum = Math.min(...arr);
3+
for (let i = 0; i < arr.length; i++) {
4+
if (arr[i] === minNum) {
5+
arr.splice(i, 1);
6+
if (arr.length === 0) {
7+
arr.push(-1);
8+
}
9+
}
10+
}
11+
return arr;
12+
}

0 commit comments

Comments
 (0)