본문 바로가기

codility4

FrogJmp FrogJmpCount minimal number of jumps from position X to Y.Task descriptionA small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.Count the minimal number of jumps that the small frog must perform to reach its target.Write a function:class Soluti.. 2016. 7. 12.
OddOccurrencesInArray 1. OddOccurrencesInArrayFind value that occurs in odd number of elements.Task descriptionA 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] = .. 2016. 7. 12.
CyclicRotation 1. CyclicRotationRotate an array to the right by a given number of steps.Task descriptionA 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 also moved to the first place.For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7]. The goal is to rotate array A K .. 2016. 7. 12.
BinaryGap Task descriptionA 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 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number .. 2016. 7. 12.

인기글