Skip to content

Latest commit

ย 

History

History
27 lines (22 loc) ยท 624 Bytes

File metadata and controls

27 lines (22 loc) ยท 624 Bytes

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Level1 : ์—ฐ์Šต๋ฌธ์ œ ์ œ์ผ ์ž‘์€ ์ˆ˜ ์ œ๊ฑฐํ•˜๊ธฐ

class Solution {
    public int[] solution(int[] arr) {
        int l = arr.length;
        if(l==1) return new int[]{-1};
        
        int[] answer = new int[l-1];
        int min = 0;
        
        for(int i=1; i<l; i++){
            if(arr[min]>arr[i])
                min =i;
        }
    
        int index =0;
        for(int i=0; i<l; i++){
            if(i==min) continue;
            answer[index++] = arr[i];
        }
        return answer;
    }
}