Algorithm/codility
-
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..
-
Lesson4. Counting Elements - PermCheckAlgorithm/codility 2018. 7. 23. 16:04
PermCheck - Check whether array A is a permutation.https://app.codility.com/programmers/lessons/4-counting_elements/perm_check/문제요약N개의 정수 배열 A가 있을 때, 1부터 N까지 한 번씩 나오면 permutation이라고 한다. A가 permutation이면 1, 아니면 0을 반환Assume that:N is an integer within the range [1..100,000];each element of array A is an integer within the range [1..1,000,000,000].Complexity:expected worst-case time complexity is O..
-
Lesson3. Time Complexity - PermMissingElemAlgorithm/codility 2018. 7. 23. 15:49
PermMissingElem - Find the missing element in a given permutation.https://app.codility.com/programmers/lessons/3-time_complexity/perm_missing_elem/문제요약길이가 N인 정수 배열 A가 있고, A가 1..(N+1)의 정수를 포함한다고 할 때 배열에 없는 하나의 정수를 찾아라.Assume that:N is an integer within the range [0..100,000];the elements of A are all distinct;each element of array A is an integer within the range [1..(N + 1)].Complexity:expected ..
-
Lesson3. Time Complexity - FrogJmpAlgorithm/codility 2018. 7. 23. 15:44
FrogJmp - Count minimal number of jumps from position X to Y.https://app.codility.com/programmers/lessons/3-time_complexity/frog_jmp/문제요약개구리가 X에서 Y이상으로 가려고 하고, 한 번에 고정된 길이 D만큼 점프를 한다고 하면 X에서 Y이상으로 가기 위한 최소 점프 수를 계산Assume that:X, Y and D are integers within the range [1..1,000,000,000];X ≤ Y.Complexity:expected worst-case time complexity is O(1);expected worst-case space complexity is O(1).풀이