jmanalang3 / CodilityLessons

Solutions solved in Swift 4.2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Codility Lessons Build Status

All lessons solved in Swift 4.2

Correctness: 100%🔥

Performance: 100%🔥

Finished lessons:

Lesson 1 - Iterations (https://app.codility.com/programmers/lessons/1-iterations/)

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

Lesson 2 - Arrays (https://app.codility.com/programmers/lessons/2-arrays/)

  • OddOccurrencesInArray: Find value that occurs in odd number of elements.
  • CyclicRotation: Rotate an array to the right by a given number of steps.

Lesson 3 - Time Complexity (https://app.codility.com/programmers/lessons/3-time_complexity/)

  • 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])|.

Lesson 4 - Counting Elements (https://app.codility.com/programmers/lessons/4-counting_elements/)

  • 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.
  • MissingInteger: Find the minimal positive integer not occurring 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 (https://app.codility.com/programmers/lessons/5-prefix_sums/)

  • PassingCars: Count the number of passing cars on the road.
  • GenomicRangeQuery: Find the minimal nucleotide from a range of sequence DNA.
  • MinAvgTwoSlice: Find the minimal average of any slice containing at least two elements.
  • CountDiv: Compute number of integers divisible by k in range [a..b].

Lesson 6 - Sorting (https://app.codility.com/programmers/lessons/6-sorting/)

  • Distinct: Compute number of distinct values in an array.
  • 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.
  • NumberOfDiscIntersections: Compute the number of intersections in a sequence of discs.

Lesson 7 - Stacks and Queues (https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

  • Brackets: Determine whether a given string of parentheses is properly nested.
  • Fish: N voracious fish are moving along a river. Calculate how many fish are alive.
  • Nesting: Determine whether given string of parentheses is properly nested.
  • StoneWall: Cover "Manhattan skyline" using the minimum number of rectangles.

Lesson 8 - Leader (https://app.codility.com/programmers/lessons/8-leader/)

  • 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.

Lesson 9 - Maximum slice problem (https://app.codility.com/programmers/lessons/9-maximum_slice_problem/)

  • MaxSliceSum: Find a maximum sum of a compact subsequence of array elements.
  • MaxProfit: Given a log of stock prices compute the maximum possible earning.
  • MaxDoubleSliceSum: Find the maximal sum of any double slice.

Lesson 10 - Prime and composite numbers (https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

  • CountFactors: Count factors of given number n.
  • MinPerimeterRectangle: Find the minimal perimeter of any rectangle whose area equals 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 (https://app.codility.com/programmers/lessons/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 (https://app.codility.com/programmers/lessons/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.

Lesson 13 - Fibonacci numbers (https://app.codility.com/programmers/lessons/13-fibonacci_numbers/)

  • Ladder: Count the number of different ways of climbing to the top of a ladder.
  • FibFrog: Count the minimum number of jumps required for a frog to get to the other side of a river.

Lesson 14 - Binary search algorithm (https://app.codility.com/programmers/lessons/14-binary_search_algorithm/)

  • MinMaxDivision: Divide array A into K blocks and minimize the largest sum of any block.
  • NailingPlanks: Count the minimum number of nails that allow a series of planks to be nailed.

Lesson 15 - Caterpillar method (https://app.codility.com/programmers/lessons/15-caterpillar_method/)

  • CountDistinctSlices: Count the number of distinct slices (containing only unique numbers).
  • CountTriangles: Count the number of triangles that can be built from a given set of edges.
  • AbsDistinct: Compute number of distinct absolute values of sorted array elements.
  • MinAbsSumOfTwo: Find the minimal absolute value of a sum of two elements.

Lesson 16 - Greedy algorithms (https://app.codility.com/programmers/lessons/16-greedy_algorithms/)

  • MaxNonoverlappingSegments: Find a maximal set of non-overlapping segments.
  • TieRopes: Tie adjacent ropes to achieve the maximum number of ropes of length >= K.

Lesson 17 - Dynamic programming (https://app.codility.com/programmers/lessons/17-dynamic_programming/)

  • NumberSolitaire: In a given array, find the subset of maximal sum in which the distance between consecutive elements is at most 6.
  • MinAbsSum: Given array of integers, find the lowest absolute sum of elements.

Lesson 90 - Tasks from Indeed Prime 2015 challenge (https://app.codility.com/programmers/lessons/90-tasks_from_indeed_prime_2015_challenge/)

  • LongestPassword: Given a string containing words, find the longest word that satisfies specific conditions.
  • FloodDepth: Find the maximum depth of water in mountains after a huge rainfall.
  • SlalomSkiing: Given a sequence, find the longest subsequence that can be decomposed into at most three monotonic parts.

Lesson 91 - Tasks from Indeed Prime 2016 challenge (https://app.codility.com/programmers/lessons/91-tasks_from_indeed_prime_2016_challenge/)

  • RectangleBuilderGreaterArea: Count the distinct rectangle sizes, of area greater than or equal to X, that can be built out of a given set of segments.
  • TreeProduct: Remove at most two edges from a tree graph to maximize the product of the components' sizes.
  • HilbertMaze: Find the shortest path between two fields in a Hilbert maze.
  • DwarfsRafting: Find out how many dwarfs can fit on a raft such that it's balanced when crossing a river.

Lesson 92 - Tasks from Indeed Prime 2016 College Coders challenge (https://app.codility.com/programmers/lessons/92-tasks_from_indeed_prime_2016_college_coders_challenge/)

  • TennisTournament: Given the numbers of players and available courts, calculate the maximum number of parallel tennis games.
  • SocksLaundering: From drawers containing both clean and dirty socks, choose socks to launder in order to obtain the maximum number of clean pairs of socks.
  • ArrayRecovery: Recover a broken array using partial information in another array.
  • DiamondsCount: Given points on a plane, count the number of sets of four points that form regular diamonds.

Lesson 99 - Future training (https://app.codility.com/programmers/lessons/99-future_training/)

  • SqlSum: Calculate sum of elements.
  • StrSymmetryPoint: Find a symmetry point of a string, if any.
  • TreeHeight: Compute the height of a binary tree.
  • ArrayInversionCount: Compute number of inversion in an array.
  • PolygonConcavityIndex: Check whether a given polygon in a 2D plane is convex; if not, return the index of a vertex that doesn't belong to the convex hull.

About

Solutions solved in Swift 4.2


Languages

Language:Swift 100.0%