Python
-
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).풀이
-
Lesson2. Arrays - OddOccurrencesInArrayAlgorithm/codility 2018. 7. 23. 15:39
OddOccurrencesInArray - Find value that occurs in odd number of elements.https://app.codility.com/programmers/lessons/2-arrays/odd_occurrences_in_array/문제요약길이가 홀수인 정수 배열 A에서 한 숫자를 제외하고는 모두 두 개씩 짝으로 존재할 때, 짝이 되지 않는 숫자를 반환Assume that:N is an odd integer within the range [1..1,000,000];each element of array A is an integer within the range [1..1,000,000,000];all but one of the values in A occur an ..
-
Lesson2. Arrays - CyclicRotationAlgorithm/codility 2018. 7. 23. 15:33
CyclicRotation - Rotate an array to the right by a given number of steps.https://app.codility.com/programmers/lessons/2-arrays/cyclic_rotation/문제요약배열 A와 정수 K가 주어지면 A를 오른쪽으로 K번 shift해서 반환Assume that:N and K are integers within the range [0..100];each element of array A is an integer within the range [−1,000..1,000]. In your solution, focus on correctness. The performance of your solution will not..