Algorithm/codility
-
Lesson7. Stacks and Queues - NestingAlgorithm/codility 2018. 7. 24. 15:14
Nesting - Determine whether a given string of parentheses (single type) is properly nested.https://app.codility.com/programmers/lessons/7-stacks_and_queues/nesting/문제요약길이 N의 문자열 S가 있을 때 다음 조건을 만족하면 nested라고 한다.S는 빈문자열S는 U가 nested일 경우 "(U)"형태S는 V와 W가 nested일 경우 "VW"의 형태주어진 문자열 S가 nested면 1, 아니면 0을 반환한다. (괄호 짝 맞추기)Assume that:N is an integer within the range [0..1,000,000];string S consists only o..
-
Lesson6. Sorting - NumberOfDiscIntersectionsAlgorithm/codility 2018. 7. 24. 15:08
NumberOfDiscIntersections - Compute the number of intersections in a sequence of discs. https://app.codility.com/programmers/lessons/6-sorting/number_of_disc_intersections/ 문제요약 0부터 N-1까지 N개의 disc를 평면에 그린다. N개의 음이 아닌 정수 배열 A는 disc의 반지름을 나타내고 j번째 disc는 (j,0)을 중심으로 반지름 A[j]으로 그려진다. J와 K가 같지 않고 J번째 disc와 K번째 disc가 최소 한 점이상의 공통 point를 가질 때 intersect하다고 한다. A에서 intersect하는 disc 쌍의 갯수를 반환하고, 쌍의 수가 10,..
-
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를 찾아라.쉽게 정리하면, 문자열에..