Algorithm

Codility 풀이 (JAVA) (ing)

백셀건전지 2022. 4. 14. 14:25

OddOccurencesInArray

 

FrogJump

 

PermMissingElem

 

TapeEquilibrium

  1. https://app.codility.com/demo/results/training78SQYY-VEW/ (53/100)
    이중 for 문으로 하게 되면 시간복잡도가 O(N * N)으로 되므로 점수가 안나옴
  2. https://app.codility.com/demo/results/trainingZFAPUX-Q7N/ (100/100)
    단일 for문으로만 처리하도록, 절대 값은 Math.abs()사용, 초기 result 값 init은 Integer.MAX_VALUE 사용
    시간 복잡도 O(N)

 

FrogRiverOne

 

PermCheck

  1. https://app.codility.com/demo/results/trainingAT6FRK-HE7/ (66/100)
    1~n까지 sum 이용하여 int[] A를 for 문 돌면서 빼도록 코딩했는데, antiSum에서 걸리고 큰 숫자에서도 오답으로 나옴.
  2. https://app.codility.com/demo/results/trainingTQB2JN-ZKH/ (83/100)
    int[] A를 Arrays.sort() 로 정렬한 후에, for문을 돌면서 A[i]와 A[i-1]이 같으면 permutation 아니라고 변경
    그럴 바엔 A를 정렬한 다음에 for문으로 i랑 A[i-1]이 다르면 순열 아니라고 체크하면 끝. sum 할 필요 없음
  3. https://app.codility.com/demo/results/training3S69F3-A4C/(100/100)