
1. BinaryGapA binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binar

2-1. CyclicRotaionAn array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the

2-2. OddOccurrencesInArrayA non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the

3-1. FrogJmpA 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 greate

3-2. PremMissingElemAn array A consisting of N different integers is given. The array contains integers in the range 1..(N + 1), which means that exac

3-3. TapeEquilibriumA non-empty array A consisting of N integers is given. Array A represents numbers on a tape.Any integer P, such that 0 < P <

4-1. FrogRiverOneA small frog wants to get to the other side of a river. The frog is initially located on one bank of the river (position 0) and wants

4-2. PermCheck A non-empty array A consisting of N integers is given.A permutation is a sequence containing each element from 1 to N once, and only on

4-3. MaxCountersYou are given N counters, initially set to 0, and you have two possible operations on them:increase(X) − counter X is increased by 1,m

4-4. MissingIntegerThis is a demo task.Write a function:class Solution { public int solution(int\[] A); }that, given an array A of N integers, returns

5-1. PassingCarsA non-empty array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road.Array

5-2. CountDivWrite a function:class Solution { public int solution(int A, int B, int K); }that, given three integers A, B and K, returns the number of

5-3. GenomicRangeQueryFor example, consider string S = CAGCCTA and arrays P, Q such that:The answers to these M = 3 queries are as follows:The part of

5-4. MinAvgTwoSliceA non-empty array A consisting of N integers is given. A pair of integers (P, Q), such that 0 ≤ P < Q < N, is called a slice

Codility_Distinct6-1. DistinctWrite a functionclass Solution { public int solution(int\[] A); }that, given an array A consisting of N integers, return

6-2. MaxProductOfThreeA non-empty array A consisting of N integers is given. The product of triplet (P, Q, R) equates to AP AQ AR (0 ≤ P < Q <
6-3. Triangle An array A consisting of N integers is given. A triplet (P, Q, R) is triangular if 0 ≤ P A[R], A[Q] + A[R] > A[P], A[R] + A[P] > A[Q]. For example, consider array A such that: A[0] =...

6-4.NumberOfDiscIntersectionsWe draw N discs on a plane. The discs are numbered from 0 to N − 1. An array A of N non-negative integers, specifying the

7-1. BracketsA string S consisting of N characters is considered to be properly nested if any of the following conditions is true:S is empty;S has the

7-2. FishYou are given two non-empty arrays A and B consisting of N integers. Arrays A and B represent N voracious fish in a river, ordered downstream

7-3. NestingA string S consisting of N characters is called properly nested if:S is empty;S has the form "(U)" where U is a properly nested string;S h

7-4. StoneWallYou are going to build a stone wall. The wall should be straight and N meters long, and its thickness should be constant; however, it sh

8-1. DominatorAn array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elements of A.F

8-2. EquiLeaderA non-empty array A consisting of N integers is given.The leader of this array is the value that occurs in more than half of the elemen

9-1. MaxProfitAn array A consisting of N integers is given. It contains daily prices of a stock share for a period of N consecutive days. If a single

9-2. MaxSliceSumA non-empty array A consisting of N integers is given. A pair of integers (P, Q), such that 0 ≤ P ≤ Q < N, is called a slice of arr

9-3. MaxDoubleSliceSumA non-empty array A consisting of N integers is given.A triplet (X, Y, Z), such that 0 ≤ X < Y < Z < N, is called a dou

10-1. CountFactorsA positive integer D is a factor of a positive integer N if there exists an integer M such that N = D \* M.For example, 6 is a facto

10-2. MinPerimeterRectangleAn integer N is given, representing the area of some rectangle.The area of a rectangle whose sides are of length A and B is

10-3. FlagsA non-empty array A consisting of N integers is given.A peak is an array element which is larger than its neighbours. More precisely, it is

10-4. PeaksA non-empty array A consisting of N integers is given.A peak is an array element which is larger than its neighbors. More precisely, it is

11-1. CountNonDivisibleYou are given an array A consisting of N integers.For each number Ai such that 0 ≤ i < N, we want to count the number of ele