슈콩

[프로그래머스] Lv.1 없는 숫자 더하기 본문

Algorithms/Programmers

[프로그래머스] Lv.1 없는 숫자 더하기

shukong 2026. 4. 6. 22:03

[문제]

https://school.programmers.co.kr/learn/courses/30/lessons/86051

 

프로그래머스

SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

 

[소스 코드]

class Solution {
    public int solution(int[] numbers) {
        int answer = 0;
        boolean[] num = new boolean[10];
        for(int i=0;i<numbers.length;i++){
            num[numbers[i]] = true;
        }
        for(int i=1;i<=9;i++){
            if(!num[i]) answer += i;
        }
        return answer;
    }
}