Giter Club home page Giter Club logo

codility-lesson-solutions's Introduction

My solutions to Codility's online lessons' tasks

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/

Lesson 1: Iterations

BinaryGap

  • Find longest sequence of zeros in binary representation of an integer.

Lesson 2: Arrays

CyclicRotation

  • Rotate an array to the right by a given number of steps.

OddOccurrencesInArray

  • Find value that occurs in odd number of elements.

Lesson 3: Time Complexity

TapeEquilibrium

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

FrogJmp

  • Count minimal number of jumps from position X to Y.

PermMissingElem

  • Find the missing element in a given permutation.

Lesson 4: Counting Elements

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.

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.

Lesson 5: Prefix Sums

CountDiv

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

PassingCars

  • Count the number of passing cars on the road.

MinAvgTwoSlice

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

GenomicRangeQuery

  • Find the minimal nucleotide from a range of sequence DNA.

Lesson 6: Sorting

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.

Lesson 7: Stacks and Queues

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.

Lesson 8: Leader

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.

Lesson 9: Maximum Slice Problem

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.

Lesson 10: Prime and Composite Numbers

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.

Lesson 11: Sieve of Eratosthenes

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.

Lesson 12: Euclidean algorithm

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.

codility-lesson-solutions's People

Contributors

ghananigans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.