일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- java 파티
- ipfs bean
- kotiln functional interface
- Java Call By Refernce
- ipfs singletone
- javav 1676
- rabbitmq 싱글톤
- java 1509
- mongodb lookup
- spring mongoTemplate switch
- go
- nodejs rabbitmq
- spring mongodb switch
- java 1238
- java 팩토리얼 개수
- 자바 백준 팩토리얼 개수
- Spring ipfs
- 익명 객체 @transactional
- Claude Intelij 연결
- 자바 1676
- 백준 1504 java
- 백준 2252 줄세우기
- spring mongodb
- kotiln const
- java 백준 1509
- 안정해시
- spring mongoTemplate
- kotiln const val
- 백준 특정한 최단 경로
- 백준 연결요소 자바
Archives
- Today
- Total
공부 흔적남기기
프로그래머스 없는 숫자 더하기 본문
728x90
반응형
import java.util.ArrayList;
class Solution {
public int solution(int[] numbers) {
int answer = 0;
ArrayList<Integer> arrayList = new ArrayList<>();
// 일반 배열은 일일이 있는지 없는지 찾기 번거롭다
//그래서 arrayList의 contains를 사용하기 위해 arrayList 생성
for (int number : numbers) {
arrayList.add(number);
}// arrayList에 배열 값들 복사시킴
for(int i =0; i<10; i++){
//arrayList에 값이 존재하지 않는다면 answer에 더해서 리턴해줌
if(!arrayList.contains(i)){
answer += i;
}
}
return answer;
}
}
출처: https://programmers.co.kr/learn/courses/30/lessons/86051
코딩테스트 연습 - 없는 숫자 더하기
0부터 9까지의 숫자 중 일부가 들어있는 배열 numbers가 매개변수로 주어집니다. numbers에서 찾을 수 없는 0부터 9까지의 숫자를 모두 찾아 더한 수를 return 하도록 solution 함수를 완성해주세요. 제한
programmers.co.kr
728x90
반응형
'코테 > 프로그래머스' 카테고리의 다른 글
프로그래머스 핸드폰 번호 가리기 (0) | 2022.01.15 |
---|---|
프로그래머스 평균 구하기 (0) | 2022.01.15 |
프로그래머스 문자열을 정수로 바꾸기 (0) | 2022.01.15 |
프로그래머스 두 정수 사이의 합 (0) | 2022.01.15 |
프로그래머스 짝수와 홀수 (0) | 2022.01.15 |