Algorithm
-
Lesson6. Sorting - DistinctAlgorithm/codility 2018. 7. 24. 14:20
Distinct - Compute number of distinct values in an array.https://app.codility.com/programmers/lessons/6-sorting/distinct/문제요약N개의 정수 배열 A가 주어지면, A의 유일한 값의 갯수를 반환(중복을 제거한)Complexity:expected worst-case time complexity is O(N*log(N));expected worst-case space complexity is O(N) (not counting the storage required for input arguments).풀이정렬 후에 이전값과 다른 값의 갯수만 센다.
-
Lesson5. Prefix Sums - GenomicRangeQueryAlgorithm/codility 2018. 7. 23. 20:00
GenomicRangeQuery - Find the minimal nucleotide from a range of sequence DNA.https://app.codility.com/programmers/lessons/5-prefix_sums/genomic_range_query/문제요약nucleotide인 문자 A,C,G,T로 구성된 문자열로 표현되는 DNA sequence가 있고, 각각의 impact factor는 1,2,3,4. 주어지는 query들에 대한 가장 작은 impact factor를 계산. query는 P, Q로 주어지고 각 index별로 DNA의 범위를 의미한다. DNA sequence의 P[K] ~ Q[K]의 범위에서 가장 작은 impact factor를 찾아라.쉽게 정리하면, 문자열에..
-
Lesson4. Counting Elements - MaxCountersAlgorithm/codility 2018. 7. 23. 16:29
MaxCounters - Calculate the values of counters after applying all alternating operations: increase counter by 1; set value of all counters to current maximum.https://app.codility.com/programmers/lessons/4-counting_elements/max_counters/문제요약0으로 초기화 된 N개의 counter가 주어지면, 아래 두 operation에 따라 처리를 하고 최종 결과를 반환increase(X) - counter X를 1증가max counter - 전체 counter를 현재 최대 값으로 모두 설정operation은 입력 A로 주어지고, A[..
-
Lessons4. Counting Elements - MissingIntegerAlgorithm/codility 2018. 7. 23. 16:15
MissingInteger - Find the smallest positive integer that does not occur in a given sequence.문제요약정수 배열 A에 나타나지 않는 가장 작은 양의 정수를 반환Assume that: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].Complexity:expected worst-case time complexity is O(N);expected worst-case space complexity is O(N) (not counting the storage require..
-
Lesson4. Counting Elements - FrogRiverOneAlgorithm/codility 2018. 7. 23. 16:10
FrogRiverOne - Find the earliest time when a frog can jump to the other side of a river.https://app.codility.com/programmers/lessons/4-counting_elements/frog_river_one/문제요약정수 배열 A에서 1부터 X까지 모두 등장하는 index를 반환, 없으면 -1반환Assume that:N and X are integers within the range [1..100,000];each element of array A is an integer within the range [1..X].Complexity:expected worst-case time complexity is O(N);e..