Algorithm/codility
-
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..
-
Lesson1. Iteration - BinaryGapAlgorithm/codility 2018. 7. 23. 15:24
BinaryGap - Find longest sequence of zeros in binary representation of an integer.https://app.codility.com/programmers/lessons/1-iterations/binary_gap/문제요약양의 정수 N의 2진 표현에서 1로 감싸진 연속된 0의 최대 갯수를 계산. 포함하지 않으면 0을 반환Assume that:N is an integer within the range [1..2,147,483,647].Complexity:expected worst-case time complexity is O(log(N));expected worst-case space complexity is O(1).풀이각 자리 bit를 검사하면 l..