Deep_Dev
article thumbnail

 


๋‚˜๋Š” ์ฒ˜์Œ์— ๋ฆฌ์ŠคํŠธ ๋ฐ˜๋ณต๋ฌธ์„ ๋Œ๋ ค์„œ ํฌํ•จ๋˜์–ด ์žˆ์ง€ ์•Š์€์ˆ˜๋ฉด answer์— ๋”ํ•ด์ฃผ๋Š” ์‹์œผ๋กœ ์ƒ๊ฐํ–ˆ์—ˆ๋Š”๋ฐ

0~9๋ถ€ํ„ฐ ์—†๋Š” ์ˆซ์ž์˜ ํ•ฉ์€, ์ด ํ•ฉ์—์„œ ์žˆ๋Š” ์ˆซ์ž๋ฅผ ๋บด์ฃผ๋ฉด ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ๋กœ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค...


class Solution {
    public int solution(int[] numbers) {
       int answer=45; // 0~9๊นŒ์ง€์˜ ํ•ฉ
        for(int x: numbers){
            answer-=x;
        }
        return answer;
    }
}