CopyPastor

Detecting plagiarism made easy.

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

Possible Plagiarism

Plagiarized on 2019-10-15
by Aravinda Weerasekara

Original Post

Original - Posted on 2016-02-06
by pro



            
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; } }
A javascript solution with 100% passing result:
function solution(A) { A.sort(function(a,b){ return a - b; }); var count = 0; for(i = 0; i < A.length; i++){ if(A[i] === i+1){ count++; } else { break; } } if(count === A.length){ return 1; } else { return 0; } }

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