오늘은 코딜리티(codility) Lesson2 OddOccurrencesInArray 문제 풀이를 포스팅 하려고 합니다.
저도 개발을 계속 배워나가고 있기 때문에 문제 풀이에 대해
고쳐야 할 점들과 다른 풀이 방법들을 댓글로 주시면 감사하겠습니다.
코딜리티에 잘 모르시는 분들은 아래 링크를 통해 먼저 보고 오셔도 좋을 것 같습니다.
[Develope/코딩 테스트] - 코딜리티(codility)
코딜리티(codility)
알고리즘, 코딩테스트를 할 수있는 다양한 사이트들이 있습니다. 요즘에는 IT 기업들이 코딩테스트를 통해 직원들을 뽑는경우가 많이 있습니다. 테스트를 하기 위한 시험 문제를 기업이 자체적으로 만드는 경우도..
bono915.tistory.com
코딜리티(codility) Lesson2 OddOccurrencesInArray의 문제입니다.

아래에는 제가 문제 풀이한 내용입니다.
// 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
int result = 0;
int totalcount = 0;
for(int i=0; i<A.length;i++) {
// System.out.println(i);
for(int j=0; j<A.length;j++) {
if(i!=j) {
if(A[i]==A[j]) {
// System.out.println("중복 값 : " + A[i]);
break;
}else {
// System.out.println("중복 아닌 값 : " + A[i]);
totalcount++;
}
}
}
// System.out.println("totalcount : " + totalcount);
// System.out.println("A.length-1 : " + (A.length-1));
if(totalcount == (A.length-1)) {
result = A[i];
return result;
}else {
totalcount =0;
}
}
return result;
}
}
Run Tests 했을때 successful이 떨어졌기 때문에
문제는 없어보입니다. 최종 제출해보겠습니다.

결과는 나왔지만.... 점수가... 55%로 저조합니다.....
퍼포먼스가 많이 떨어져서 그런 것 같네요.....
댓글로 많은 도움을 부탁드립니다.....

Lesson1보다 테스트된 양은 많지 않아보이는데 퍼포먼스에서 OK가 1개밖에 없습니다.
제 소스에 문제가 많은 듯 합니다. 일단은 풀긴 풀었으니.... 넘어가봅니다....


'Develope > 코딩 테스트' 카테고리의 다른 글
[Toss] 코딩테스트 JavaScript 더치페이에서 돈 나누기 (0) | 2020.08.02 |
---|---|
[Toss] 코딩테스트 JavaScript 개인정보를 지켜라! (0) | 2020.08.02 |
코딜리티(codility) Lesson2 CyclicRotation 문제 풀이(JAVA) (2) | 2019.09.13 |
코딜리티(codility) Lesson1 BinaryGap 문제 풀이(JAVA) (2) | 2019.09.13 |
코딜리티(codility) (2) | 2019.05.01 |
오늘은 코딜리티(codility) Lesson2 OddOccurrencesInArray 문제 풀이를 포스팅 하려고 합니다.
저도 개발을 계속 배워나가고 있기 때문에 문제 풀이에 대해
고쳐야 할 점들과 다른 풀이 방법들을 댓글로 주시면 감사하겠습니다.
코딜리티에 잘 모르시는 분들은 아래 링크를 통해 먼저 보고 오셔도 좋을 것 같습니다.
[Develope/코딩 테스트] - 코딜리티(codility)
코딜리티(codility)
알고리즘, 코딩테스트를 할 수있는 다양한 사이트들이 있습니다. 요즘에는 IT 기업들이 코딩테스트를 통해 직원들을 뽑는경우가 많이 있습니다. 테스트를 하기 위한 시험 문제를 기업이 자체적으로 만드는 경우도..
bono915.tistory.com
코딜리티(codility) Lesson2 OddOccurrencesInArray의 문제입니다.

아래에는 제가 문제 풀이한 내용입니다.
// 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
int result = 0;
int totalcount = 0;
for(int i=0; i<A.length;i++) {
// System.out.println(i);
for(int j=0; j<A.length;j++) {
if(i!=j) {
if(A[i]==A[j]) {
// System.out.println("중복 값 : " + A[i]);
break;
}else {
// System.out.println("중복 아닌 값 : " + A[i]);
totalcount++;
}
}
}
// System.out.println("totalcount : " + totalcount);
// System.out.println("A.length-1 : " + (A.length-1));
if(totalcount == (A.length-1)) {
result = A[i];
return result;
}else {
totalcount =0;
}
}
return result;
}
}
Run Tests 했을때 successful이 떨어졌기 때문에
문제는 없어보입니다. 최종 제출해보겠습니다.

결과는 나왔지만.... 점수가... 55%로 저조합니다.....
퍼포먼스가 많이 떨어져서 그런 것 같네요.....
댓글로 많은 도움을 부탁드립니다.....

Lesson1보다 테스트된 양은 많지 않아보이는데 퍼포먼스에서 OK가 1개밖에 없습니다.
제 소스에 문제가 많은 듯 합니다. 일단은 풀긴 풀었으니.... 넘어가봅니다....


'Develope > 코딩 테스트' 카테고리의 다른 글
[Toss] 코딩테스트 JavaScript 더치페이에서 돈 나누기 (0) | 2020.08.02 |
---|---|
[Toss] 코딩테스트 JavaScript 개인정보를 지켜라! (0) | 2020.08.02 |
코딜리티(codility) Lesson2 CyclicRotation 문제 풀이(JAVA) (2) | 2019.09.13 |
코딜리티(codility) Lesson1 BinaryGap 문제 풀이(JAVA) (2) | 2019.09.13 |
코딜리티(codility) (2) | 2019.05.01 |