/Codility

Primary LanguagePython

Codility

Problem solutions for Codility 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.

PermMissingElem

Find the missing element in a given permutation.

FrogJmp

Count minimal number of jumps from position X to Y.

TapeEquilibrium

Minimize the value |(A[0] + ... + A[P-1]) - (A[P] + ... + A[N-1])|.

PermCheck

Check whether array A is a permutation.

FrogRiverOne

Find the earliest time when a frog can jump to the other side of a river.

MaxCounters

Calculate the values of counters after applying all alternating operations: increase counter by 1; set value of all counters to current maximum.

MissingInteger

Find the smallest positive integer that does not occur in a given sequence.

PassingCars

Count the number of passing cars on the road.

CountDiv

Compute number of integers divisible by k in range [a..b].

GenomicRangeQuery

Find the minimal nucleotide from a range of sequence DNA.

MinAvgTwoSlice

Find the minimal average of any slice containing at least two elements.

Distinct

Compute number of distinct values in an array.

MaxProductOfThree

Maximize A[P] * A[Q] * A[R] for any triplet (P, Q, R).

NumberOfDiscIntersections

Compute the number of intersections in a sequence of discs.

Nesting

Determine whether a given string of parentheses (single type) is properly nested.

Brackets

Determine whether a given string of parentheses (multiple types) is properly nested.

Nesting

Determine whether a given string of parentheses (single type) is properly nested.

Nesting

Determine whether a given string of parentheses (single type) is properly nested.

Fish

N voracious fish are moving along a river. Calculate how many fish are alive.

StoneWall

Cover "Manhattan skyline" using the minimum number of rectangles.

Your score on this task 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.

Dominator

Find an index of an array such that its value occurs at more than half of indices in the array.

MaxProfit

Given a log of stock prices compute the maximum possible earning.

MaxSliceSum

Find a maximum sum of a compact subsequence of array elements.

CountFactors

Count factors of given number n.