728x90
반응형
처음에 아무 생각 없이 정렬해서 가장 작은 수를 지워버렸는데 그런 문제가 아니였다. 배열 안에서 가장 작은 수만 제거 하면 된다. 이게 왜 9점이나 줬을까.
제일 작은 수 제거하기 문제
내 코드
using System;
using System.Collections.Generic;
//+9
public class Solution {
public int[] solution(int[] arr) {
int min = arr[0];
List<int> answer = new List<int>(arr);
if (arr.Length == 1) answer.Add(-1);
else
{
for (int i = 0; i < arr.Length; i++)
{
if(min > arr[i]) min = arr[i];
}
}
answer.Remove(min);
return answer.ToArray();
}
}
728x90
반응형
'코딩테스트_c# > 프로그래머스' 카테고리의 다른 글
프로그래머스 ) Summer/Winter Coding(~2018) - 영어 끝말잇기 Level.2_C# +테스트 케이스 추가 (0) | 2024.03.04 |
---|---|
프로그래머스 ) 코딩테스트 입문 - 다항식 더하기 Level.0_C# (0) | 2024.02.28 |
프로그래머스 ) 연습문제 - 야근지수 Level3_C# (0) | 2024.02.19 |
프로그래머스 ) 코딩테스트 연습 - 숫자게임 Level.3_C# (0) | 2024.02.19 |
프로그래머스 ) 연습문제 - 혼자서 하는 틱택토 Level.2_C# (0) | 2024.02.14 |