Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 백준
- 백준16937
- 백준 타일코드
- 백준 도서관
- java
- ChatOpenAI
- Frog River One
- 백준 시간초과
- 백준3078 풀이
- 두 개의 배열
- 백준1720
- LangChain
- 백준3078
- 백준11332
- 백준1461
- 백준13417
- 교수님의 기말고사풀이
- streamlit
- 백준20126
- liquibse
- 백준17124
- 두 스티커
- 백준1802
- BaseCallbackHandler
- 외판원순회
- Codility
- 백준2098
- generateChangeLog
- streaming chat
- export changeLog
Archives
- Today
- Total
tempcru 삽질기록
Codility - Perm Missing Elem 풀이 (java) 본문
문제
https://app.codility.com/programmers/lessons/3-time_complexity/perm_missing_elem/
PermMissingElem coding task - Learn to Code - Codility
Find the missing element in a given permutation.
app.codility.com
- 배열에서 없는 숫자하나 찾아라~~
접근방법
- 주어진 배열안에 들어갈 숫자가 최대 10만 1 이므로
- value를 index로 하는 boolean 배열 하나 만들어서 exist 체크
풀이
public class PermMissingElem {
public static void main(String[] args) {
int[] A = {2, 3, 1, 5};
System.out.println(solution(A));
}
private static int solution(int[] A) {
// init
int result = 0;
boolean[] test = new boolean[A.length + 2];
//logic
for(int i : A) {
test[i] = true;
}
for(int i = 1; i < test.length; i++) {
if(!test[i]) {
result = i;
break;
}
}
return result;
}
}
'Coding Test > Codility' 카테고리의 다른 글
Codility - Binary Gap 풀이 (java8) (0) | 2022.01.05 |
---|---|
Codility - Cyclic Rotation 풀이 (java8) (0) | 2022.01.05 |
Codility - Odd Occurrences In Array 풀이 (Java8) (0) | 2022.01.05 |
Codility - Frog Jmp 풀이 (java) (0) | 2022.01.05 |
Codility - Tape Equilibrium 풀이 (java) (0) | 2022.01.05 |