A non-empty zero-indexed array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.For example, in array A such that: A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9the elements at indexes 0 and 2 have value 9,the ele..
코딜리티 알고리즘 연습 두번째 포스팅. A zero-indexed array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is moved to the first place).The goal is to rotate array ..
알고리즘 공부를 해야지 해야지 하다가 이제서야 시작. 코딜리티(Codility)라는 좋은 사이트를 접하게 되어서 문제를 풀어보기로 마음먹었다. 코딜리티로 문제를 풀고나면 복잡도(Big-o)도 계산해주고 스코어도 매겨준다. 첫번째 문제. A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529..