CopyPastor

Detecting plagiarism made easy.

Score: 0.803979218006134; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-10-15
by Aravinda Weerasekara

Original Post

Original - Posted on 2015-07-26
by joaoprudencio



            
Present in both answers; Present only in the new answer; Present only in the old answer;

I used this java code as a solution. Got 100%
class Solution { public int solution(int[] A) { int result = 0; Set<Integer> set = new HashSet<>(); for (int x : A) { set.add(x); } for (int x = 1; x < set.size() + 2; x++) { if (!set.contains(x)) { result = x; } } return result; } }
Here is my answer, got [100/100](https://app.codility.com/demo/results/demoDEX92K-GJJ/).

import java.util.HashSet;
class Solution { public int solution(int[] A) { int num = 1; HashSet<Integer> hset = new HashSet<Integer>(); for (int i = 0 ; i < A.length; i++) { hset.add(A[i]); }
while (hset.contains(num)) { num++; } return num; } }

        
Present in both answers; Present only in the new answer; Present only in the old answer;