Tasks Details
medium
Find the smallest positive integer that does not occur in a given sequence.
Task Score
100%
Correctness
100%
Performance
100%
This is a demo task.
Write a function:
class Solution { public int solution(int[] A); }
that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.
For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.
Given A = [1, 2, 3], the function should return 4.
Given A = [−1, −3], the function should return 1.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Copyright 2009–2024 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.
Solution
Programming language used Java 8
Time spent on task 107 minutes
Notes
not defined yet
Task timeline
Code: 06:23:06 UTC,
java,
autosave
Code: 06:23:18 UTC,
java,
autosave
Code: 06:23:49 UTC,
java,
autosave
Code: 06:24:00 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
for(int i=0; i<A.length; i++){
}
}
}
Code: 06:24:44 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
for(int i=0; i<A.length; i++){
}
}
}
Code: 06:24:54 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Hashset
for(int i=0; i<A.length; i++){
}
}
}
Code: 06:25:17 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark =
for(int i=0; i<A.length; i++){
}
}
}
Code: 06:25:38 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
}
}
Code: 06:49:31 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
if
}
}
Code: 06:49:50 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
if(mark.size() == A.length){
}
}
}
Code: 06:57:46 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List
}
}
Code: 06:58:05 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
}
}
Code: 06:58:15 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort()
}
}
Code: 06:58:41 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort(list);
}
}
Code: 07:04:50 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort(list);
}
}
Code: 07:05:32 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort(list);
for
}
}
Code: 07:05:52 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.)
}
}
Code: 07:06:23 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size()
}
}
Code: 07:06:34 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
}
}
}
Code: 07:06:44 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if()
}
}
}
Code: 07:07:09 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
return i;
}
}
}
}
Analysis
Compile error
Solution.java:22: error: incomparable types: Object and int if(list.get(i) != i){ ^ Note: Solution.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Code: 07:07:19 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List< list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
return i;
}
}
}
}
Code: 07:07:23 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
return i;
}
}
}
}
Analysis
Compile error
Solution.java:27: error: missing return statement } ^ Note: Solution.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Code: 07:08:00 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
in
}
}
}
}
Code: 07:08:19 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
int N = list.get(i);
}
}
return N;
}
}
Analysis
Compile error
Solution.java:26: error: cannot find symbol return N; ^ symbol: variable N location: class Solution Note: Solution.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Code: 07:08:38 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
N = list.get(i);
}
}
return N;
}
}
Code: 07:08:46 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
N = list.get(i);
}
}
return N;
}
}
Analysis
Compile error
Solution.java:27: error: variable N might not have been initialized return N; ^ Note: Solution.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Code: 07:08:58 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
N = list.get(i);
}
}
return N;
}
}
Code: 07:08:59 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
N = list.get(i);
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 6 expected 5
1.
0.012 s
WRONG ANSWER,
got 3 expected 4
1.
0.008 s
WRONG ANSWER,
got -1 expected 1
Code: 07:09:43 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i+1){
N = list.get(i);
}
}
return N;
}
}
Code: 07:09:47 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i+1){
N = list.get(i);
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 6 expected 5
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
1.
0.008 s
WRONG ANSWER,
got -1 expected 1
Code: 07:10:11 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=1; i<list.size();i++){
if(list.get(i) != i){
N = list.get(i);
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 6 expected 5
1.
0.008 s
WRONG ANSWER,
got 3 expected 4
1.
0.008 s
WRONG ANSWER,
got -1 expected 1
Code: 07:10:19 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
N = list.get(i);
}
}
return N;
}
}
Code: 07:10:36 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i){
//N = list.get(i);
System.out.println(list.get(i));
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 5
stdout:
1 2 3 4 6
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
stdout:
1 2 3
1.
0.008 s
WRONG ANSWER,
got 0 expected 1
stdout:
-3 -1
Code: 07:11:15 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=1; i<list.size();i++){
if(list.get(i) != i){
//N = list.get(i);
System.out.println(list.get(i));
}
}
return N;
}
}
Code: 07:11:17 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=1; i<list.size();i++){
if(list.get(i) != i){
//N = list.get(i);
System.out.println(list.get(i));
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.012 s
WRONG ANSWER,
got 0 expected 5
stdout:
2 3 4 6
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
stdout:
2 3
1.
0.008 s
WRONG ANSWER,
got 0 expected 1
stdout:
-1
Code: 07:12:54 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
li.sort(list);
for(int i=1; i<list.size();i++){
if(list.get(i) != i){
//N = list.get(i);
System.out.println(list.get(i));
}
}
return N;
}
}
Code: 07:12:59 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
lit.sort();
for(int i=1; i<list.size();i++){
if(list.get(i) != i){
//N = list.get(i);
System.out.println(list.get(i));
}
}
return N;
}
}
Analysis
Compile error
Solution.java:20: error: cannot find symbol lit.sort(); ^ symbol: variable lit location: class Solution Note: Solution.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Code: 07:13:07 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=1; i<list.size();i++){
if(list.get(i) != i){
//N = list.get(i);
System.out.println(list.get(i));
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 5
stdout:
2 3 4 6
1.
0.004 s
WRONG ANSWER,
got 0 expected 4
stdout:
2 3
1.
0.008 s
WRONG ANSWER,
got 0 expected 1
stdout:
-1
Code: 07:14:09 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=1; i<list.size();i++){
if(list.get(i) != i){
//N = list.get(i);
}
}
return N;
}
}
Code: 07:14:16 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=1; i<list.size();i++){
System.out.println(list.get(i));
if(list.get(i) != i){
//N = list.get(i);
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 5
stdout:
2 3 4 6
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
stdout:
2 3
1.
0.008 s
WRONG ANSWER,
got 0 expected 1
stdout:
-1
Code: 07:14:25 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
System.out.println(list.get(i));
if(list.get(i) != i){
//N = list.get(i);
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 5
stdout:
1 2 3 4 6
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
stdout:
1 2 3
1.
0.008 s
WRONG ANSWER,
got 0 expected 1
stdout:
-3 -1
Code: 07:14:57 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
System.out.println(list.get(i));
if(list.get(i) != i+1){
//N = list.get(i);
}
}
return N;
}
}
Code: 07:15:04 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i+1){
//N = list.get(i);
System.out.println(list.get(i));
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 5
stdout:
6
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
1.
0.008 s
WRONG ANSWER,
got 0 expected 1
stdout:
-3 -1
Code: 07:15:20 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i+1){
N = list.get(i);
System.out.println(list.get(i));
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 6 expected 5
stdout:
6
1.
0.012 s
WRONG ANSWER,
got 0 expected 4
1.
0.008 s
WRONG ANSWER,
got -1 expected 1
stdout:
-3 -1
Code: 07:15:48 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i+1){
System.out.println(list.get(i));
}
}
return N;
}
}
Code: 07:15:50 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i+1){
System.out.println(list.get(i));
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 5
stdout:
6
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
1.
0.012 s
WRONG ANSWER,
got 0 expected 1
stdout:
-3 -1
Code: 07:21:20 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
if(list.get(i) != i+1){
}
}
return N;
}
}
Code: 07:21:27 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
System.out.println(list.get(i));
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 5
stdout:
1 2 3 4 6
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
stdout:
1 2 3
1.
0.008 s
WRONG ANSWER,
got 0 expected 1
stdout:
-3 -1
Code: 07:21:49 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; i<list.size();i++){
System.out.println(list.get(i));
}
return N;
}
}
Code: 07:22:19 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
whi
return N;
}
}
Code: 07:22:42 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
while()
return N;
}
}
Code: 07:23:13 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int i=0; )
return N;
}
}
Code: 07:23:38 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
}
return N;
}
}
Code: 07:23:57 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
System.out.println(list.get(j));
}
return N;
}
}
Code: 07:23:59 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
System.out.println(list.get(j));
}
}
}
Analysis
Compile error
Solution.java:27: error: missing return statement } ^ Note: Solution.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Code: 07:24:06 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
System.out.println(list.get(j));
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 5
stdout:
1 2 3 4 6
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
stdout:
1 2 3
1.
0.008 s
WRONG ANSWER,
got 0 expected 1
stdout:
-3 -1
Code: 07:25:04 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
if
}
return N;
}
}
Code: 07:25:15 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
if(list.get(j)
}
return N;
}
}
Code: 07:25:32 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
}
}
return N;
}
}
Code: 07:25:42 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
}
}
return N;
}
}
Code: 07:25:52 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
OK
1.
0.008 s
WRONG ANSWER,
got 0 expected 4
1.
0.008 s
WRONG ANSWER,
got 2 expected 1
Code: 07:26:13 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
Code: 07:26:43 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if()
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
Code: 07:26:55 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(){
}else{
}
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
Code: 07:27:06 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(){
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
}
Code: 07:32:14 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(l){
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
}
Code: 07:32:28 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
}
Code: 07:32:39 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
list.
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
}
Code: 07:33:01 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1);
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
}
Code: 07:33:14 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1);
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
return N;
}
}
}
Analysis
Compile error
Solution.java:37: error: missing return statement } ^ Note: Solution.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Code: 07:33:32 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1);
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
}
}
}
Code: 07:33:43 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1);
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
}
}
}
Code: 07:34:04 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1);
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
}
return N;
}
}
Analysis
expand all
Example tests
1.
0.008 s
OK
1.
0.008 s
WRONG ANSWER,
got 3 expected 4
1.
0.008 s
WRONG ANSWER,
got -1 expected 1
Code: 07:34:15 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
}
return N;
}
}
Code: 07:34:17 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1){
N = j+1;
break;
}
}
}
return N;
}
}
Analysis
Code: 07:34:55 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1 && ){
N = j+1;
break;
}
}
}
return N;
}
}
Code: 07:35:07 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=0;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1 && list.get(j)>0){
N = j+1;
break;
}
}
}
return N;
}
}
Analysis
Code: 07:36:13 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=1;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1 && list.get(j)>0){
N = j+1;
break;
}
}
}
return N;
}
}
Code: 07:36:14 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=1;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size()){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1 && list.get(j)>0){
N = j+1;
break;
}
}
}
return N;
}
}
Analysis
Code: 07:37:08 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=1;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size() ){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1 && list.get(j)>0){
N = j+1;
break;
}
}
}
return N;
}
}
Code: 07:37:18 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=1;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size() && ){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1 && list.get(j)>0){
N = j+1;
break;
}
}
}
return N;
}
}
Code: 08:01:36 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
Set<Integer> mark = new HashSet<>();
int N=1;
for(int i=0; i<A.length; i++){
mark.add(A[i]);
}
List<Integer> list = new ArrayList(mark);
Collections.sort(list);
if(A.length == list.size() && ){
N = list.get(list.size()-1)+1;
}else{
for(int j=0; j<list.size(); j++){
if(list.get(j) != j+1 && list.get(j)>0){
N = j+1;
break;
}
}
}
return N;
}
}
Code: 08:02:08 UTC,
java,
autosave
Code: 08:02:31 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
}
}
Code: 08:03:39 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
}
}
Code: 08:03:56 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
}
}
}
Code: 08:04:12 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && )
}
}
}
Code: 08:04:29 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
}
}
}
}
Code: 08:04:39 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
}
}
Code: 08:06:21 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for
}
}
Code: 08:06:49 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for(int i=1; i<checker.length; i++){
if(checker.)
}
}
}
Code: 08:07:03 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for(int i=1; i<checker.length; i++){
if(checker[i]==false){
return
}
}
}
}
Code: 08:07:16 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for(int i=1; i<checker.length; i++){
if(checker[i]==false){
return i;
}
}
}
}
Code: 08:08:23 UTC,
java,
verify,
result: Failed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for(int i=1; i<checker.length; i++){
if(checker[i]==false){
return i;
}
}
}
}
Analysis
Compile error
Solution.java:25: error: missing return statement } ^ 1 error
Code: 08:08:30 UTC,
java,
autosave
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for(int i=1; i<checker.length; i++){
if(checker[i]==false){
return i;
}
}
return
}
}
Code: 08:08:36 UTC,
java,
verify,
result: Passed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for(int i=1; i<checker.length; i++){
if(checker[i]==false){
return i;
}
}
return checker.length;
}
}
Analysis
Code: 08:09:40 UTC,
java,
verify,
result: Passed
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for(int i=1; i<checker.length; i++){
if(checker[i]==false){
return i;
}
}
return checker.length;
}
}
Analysis
Code: 08:09:45 UTC,
java,
final,
score: 
100
// you can also use imports, for example:
import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
boolean checker[] = new boolean[A.length+1];
for(int i=0; i<A.length; i++){
int value=A[i];
if(value>0 && value<checker.length){
checker[value]=true;
}
}
for(int i=1; i<checker.length; i++){
if(checker[i]==false){
return i;
}
}
return checker.length;
}
}
Analysis summary
The solution obtained perfect score.
Analysis
Detected time complexity:
O(N) or O(N * log(N))
expand all
Correctness tests
1.
0.004 s
OK
2.
0.008 s
OK
3.
0.004 s
OK
4.
0.004 s
OK
1.
0.008 s
OK
2.
0.008 s
OK
3.
0.008 s
OK
1.
0.004 s
OK
2.
0.004 s
OK
1.
0.008 s
OK
2.
0.004 s
OK
1.
0.004 s
OK
expand all
Performance tests
1.
0.024 s
OK
2.
0.020 s
OK
3.
0.028 s
OK
1.
0.224 s
OK
1.
0.244 s
OK
2.
0.240 s
OK
1.
0.176 s
OK