All tasks and solutions will be sorted into the appropriate lessons, exactly like how codility organizes them.
Link to Lessons and tasks: https://codility.com/programmers/lessons/
BinaryGap: Find longest sequence of zeros in binary representation of an integer.
CyclicRotation: Rotate an array to the right by a given number of steps.
OddOccurrencesInArray: Find value that occurs in odd number of elements.
FrogJmp: Count minimal number of jumps from position X to Y.
PermMissingElem: Find the missing element in a given permutation.
TapeEquilibrium: Minimize the value |(A[0] + ... + A[P-1]) - (A[P] + ... + A[N-1])|.
FrogRiverOne: Find the earliest time when a frog can jump to the other side of a river.
PermCheck: Check whether array A is a permutation.
- JavaScript:
MissingInteger: Find the minimal positive integer not occuring in a given sequence.
MaxCounters: Calculate the values of counters after applying all alternating operations: increase counter by 1; set value of all counters to current maximum.
PassingCars
-
Count the number of passing cars on the road.
-
JavaScript: https://app.codility.com/demo/results/trainingYSPPWE-ZT9/
GenomicRangeQuery
-
Find the minimal nucleotide from a range of sequence DNA.
-
JavaScript:
MinAvgTwoSlice
-
Find the minimal average of any slice containing at least two elements.
-
JavaScript:
CountDiv
-
Compute number of integers divisible by k in range [a..b].
-
JavaScript:
MaxProductOfThree
- Maximize A[P]*A[Q]*A[R] for any triplet (P, Q, R).
Triangle
- Determine whether a triangle can be built from a given set of edges.
Distinct
- Compute number of distinct values in an array.
NumberOfDiscIntersections
- Compute the number of intersections in a sequence of discs.
Nesting
- Determine whether given string of parentheses is properly nested.
StoneWall
- Cover "Manhattan skyline" using the minimum number of rectangles.
Brackets
- Determine whether given string of parentheses is properly nested.
Fish
- N voracious fish are moving along a river. Calculate how many fish are still alive.
Dominator
- Find an index of an array such that its value occurs at more than half of indices in the array.
EquiLeader
- Find the index S such that the leaders of the sequences A[0], A[1], ..., A[S] and A[S + 1], A[S + 2], ..., A[N - 1] are the same.
MaxDoubleSliceSum
- Find the maximal sum of any double slice.
MaxProfit
- Given a log of stock prices compute the maximum possible earning.
MaxSliceSum
- Find a maximum sum of a compact subsequence of array elements.
MinPerimeterRectangle
- Find the minimal perimeter of any rectangle whose area equals N.
CountFactors
- Count factors of a give number n.
Peaks
- Divide an array into the maximum number of same-sized blocks, each of which should contain an index P such that A[P - 1] < A[P] > A[P + 1].
Flags
- Find the maximum number of flags that can be set on mountain peaks.
CountSemiprimes
- Count the semiprime numbers in the given range [a..b].
CountNonDivisible
- Calculate the number of elements of an array that are not divisors of each element.
ChocolatesByNumbers
- There are N chocolates in a circle. Count the number of chocolates you will eat.
CommonPrimeDivisors
- Check whether two numbers have the same prime divisors.