Skip to content

Commit 156e365

Browse files
committed
[TimeComplexity] Codility-PermMissingElem
1 parent 3b42e9f commit 156e365

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
| 04 | | [Baekjoon-2748 피보나치 수 2](./src/TimeComplexity/P2748) | DP |
6868
| 05 | | [Baekjoon-1806 부분합](./src/TimeComplexity/P1806) | 2-pointer |
6969
| 06 | | [Codility-Lesson3 FrogJmp](./src/TimeComplexity/FrogJmp) | |
70+
| 06 | | [Codility-Lesson3 PermMissingElem](./src/TimeComplexity/PermMissingElem) | |
7071

7172
## Data Structure
7273

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package TimeComplexity.PermMissingElem;
2+
3+
public class Main {
4+
public static void main(String[] args) {
5+
Solution sol = new Solution();
6+
System.out.println(sol.solution(new int[]{}));
7+
System.out.println(sol.solution(new int[]{2, 3, 1, 5}));
8+
}
9+
}
10+
11+
class Solution {
12+
public int solution(int[] A) {
13+
boolean[] checked = new boolean[A.length + 2];
14+
for (int a : A) checked[a] = true;
15+
for (int i = 1; i < checked.length; i++) {
16+
if (!checked[i]) return i;
17+
}
18+
return A.length + 1;
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## [Codility - Lesson 3 Time Complexity] PermMissingElem
2+
3+
> Detected time complexity : **O(N) or O(N * log(N))**
4+
5+
![image](https://user-images.githubusercontent.com/22045163/101918025-361bd580-3c0c-11eb-96f3-7626764d8ece.png)

0 commit comments

Comments
 (0)