Explanations in C++ for the 17 Algorithm Lessons at https://app.codility.com/programmers with Problems and Solutions
Task score : 100% - Correctness : 100% ; Performance : 100%
Detected time complexity : - See particular solution.
Click link for explanation of problem and solution below.
Category of Article : Technology | Computers and Software | Algorithm
By: Chrysanthus Date Published: 28 May 2025
- Lesson 1: Iterations Explanation Basics for app.codility.com-programmers in C++
- Practice 1: BinaryGap at app.codility.com-programmers in C++ Explained - Find longest sequence of zeros in binary representation of an integer
- Lesson 2: Arrays and Vectors Explanation for app.codility.com-programmers in C Plusplus
- Practice 1: CyclicRotation at app.codility.com-programmers in C++ Explained - Rotate an array to the right by a given number of steps
- Practice 2: OddOccurrencesInArray at app.codility.com-programmers in C++ Explained - Find value that occurs in odd number of elements
- Lesson 3: Time Complexity for app-codility-com-programmers Explained in C++
- Practice 1: FrogJmp at app-codility-com-programmers in C++ Explained - Count minimal number of jumps from position X to Y
- Practice 2: PermMissingElem at app-codility-com-programmers in C++ Explained - Find the missing element in a given permutation
- Practice 3: TapeEquilibrium at app-codility-com-programmers in C++ Explained - Minimize the value
- Lesson 4: Counting Elements for app-codility-com-programmers Explained in C++
- Practice 1: FrogRiverOne at app-codility-com-programmers in C++ Explained - Find the earliest time when a frog can jump to the other side of a river
- Practice 2: PermCheck at app-codility-com-programmers in C++ Explained - Check whether array A is a permutation
- Practice 3: MaxCounters at app-codility-com-programmers in C++ Explained - Calculate the values of counters after applying all alternating operations
- Practice 4: MissingInteger at app-codility-com-programmers in C++ Explained - Find the smallest positive integer that does not occur in a given sequence
- Lesson 5: Prefix Sums, app-codility-com-programmers Explained in C++
- Practice 1: PassingCars at app-codility-com-programmers in C++ Explained - Count the number of passing cars on the road
- Practice 2: CountDiv at app-codility-com-programmers in C++ Explained - Compute number of integers divisible by k in range a-b
- Practice 3: GenomicRangeQuery at app-codility-com-programmers in C++ Explained - Find the minimal nucleotide from a range of sequence DNA
- Practice 4: MinAvgTwoSlice at app-codility-com-programmers in C++ Explained - Find the minimal average of any slice containing at least two elements
- Lesson 6: Sorting for app.codility.com/programmers Explained in C++
- Practice 1: Distinct at app.codility.com/programmers in C++ Explained: Compute number of distinct values in an array.
- Practice 2: MaxProductOfThree at app.codility.com/programmers in C++ Explained: Maximize A[P] * A[Q] * A[R] for any triplet (P, Q, R).
- Practice 3: Triangle at app.codility.com/programmers in C++ Explained: Determine whether a triangle can be built from a given set of edges.
- Practice 4: NumberOfDiscIntersections at app.codility.com/programmers in C++ Explained: Compute the number of intersections in a sequence of discs.
- Lesson 7: Stacks and Queues for app.codility.com/programmers Explained in C++
- Practice 1: Brackets at app.codility.com/programmers in C++ Explained: Determine whether a given string of parentheses (multiple types) is properly nested.
- Practice 2: Fish at app.codility.com/programmers in C++ Explained: N voracious fish are moving along a river. Calculate how many fish are alive.
- Practice 3: Nesting at app.codility.com/programmers in C++ Explained: Determine whether a given string of parentheses (single type) is properly nested.
- Practice 4: StoneWall at app.codility.com/programmers in C++ Explained: Cover "Manhattan skyline" using the minimum number of rectangles.
- Lesson 8: Leader for app.codility.com/programmers Explained in C++
- Practice 1: Dominator at app.codility.com/programmers in C++ Explained: Find an index of an array such that its value occurs at more than half of indices in the array.
- Practice 2: EquiLeader at app.codility.com/programmers in C++ Explained: 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 for app.codility.com/programmers Explained in C++
- Practice 1: MaxProfit at app.codility.com/programmers in C++ Explained: Given a log of stock prices compute the maximum possible earning.
- Practice 2: MaxSliceSum at app.codility.com/programmers in C++ Explained: Find a maximum sum of a compact subsequence of array elements.
- Practice 3: MaxDoubleSliceSum at app.codility.com/programmers in C++ Explained: Find the maximal sum of any double slice.
- Lesson 10: Prime and Composite Numbers for app.codility.com/programmers Explained in C++
- Practice 1: CountFactors at app.codility.com/programmers in C++ Explained - Count factors of given number n
- Practice 2: MinPerimeterRectangle at app.codility.com/programmers in C++ Explained - Find the minimal perimeter of any rectangle whose area equals N
- Practice 3: Flags at app.codility.com/programmers in C++ Explained - Find the maximum number of flags that can be set on mountain peaks
- Practice 4: Peaks at app.codility.com/programmers in C++ Explained
- Lesson 11: Sieve of Eratosthenes for app.codility.com/programmers Explained in C++
- Practice 1: CountNonDivisible at app.codility.com/programmers in C++ Explained: Calculate the number of elements of an array that are not divisors of each element.
- Practice 2: CountSemiprimes at app.codility.com/programmers in C++ Explained: Count the semiprime numbers in the given range [a..b].
- Lesson 12: Euclidean Algorithm for app.codility.com/programmers Explained in C++
- Practice 1: ChocolatesByNumbers at app.codility.com/programmers in C++ Explained: There are N chocolates in a circle. Count the number of chocolates you will eat.
- Practice 2: CommonPrimeDivisors at app.codility.com/programmers in C++ Explained: Check whether two numbers have the same prime divisors.
- Lesson 13: Fibonacci Numbers for app.codility.com/programmers Explained in C++
- Practice 1: FibFrog at app.codility.com/programmers in C++ Explained: Count the minimum number of jumps required for a frog to get to the other side of a river.
- Practice 2: Ladder at app.codility.com/programmers in C++ Explained: Count the number of different ways of climbing to the top of a ladder.
- Lesson 14: Binary Search Algorithm for app.codility.com/programmers Explained in C++
- Practice 1: MinMaxDivision at app.codility.com/programmers in C++ Explained: Divide array A into K blocks and minimize the largest sum of any block.
- Practice 2: NailingPlanks at app.codility.com/programmers in C++ Explained: Count the minimum number of nails that allow a series of planks to be nailed.
- Lesson 15: Caterpillar Method for app.codility.com/programmers Explained in C++
- Practice 1: AbsDistinct at app.codility.com/programmers in C++ Explained: Compute number of distinct absolute values of sorted array elements.
- Practice 2: CountDistinctSlices at app.codility.com/programmers in C++ Explained: Count the number of distinct slices (containing only unique numbers).
- Practice 3: CountTriangles at app.codility.com/programmers in C++ Explained: Count the number of triangles that can be built from a given set of edges.
- Practice 4: MinAbsSumOfTwo at app.codility.com/programmers in C++ Explained: Find the minimal absolute value of a sum of two elements.
- Lesson 16: Greedy Algorithms for app.codility.com/programmers Explained in C++
- Practice 1: MaxNonoverlappingSegments at app.codility.com/programmers in C++ Explained: Find a maximal set of non-overlapping segments.
- Practice 2: TieRopes at app.codility.com/programmers in C++ Explained: Tie adjacent ropes to achieve the maximum number of ropes of length >= K.
- Lesson 17: Dynamic Programming for app.codility.com/programmers Explained in C++
- Practice 1: NumberSolitaire at app.codility.com/programmers in C++ Explained: In a given array, find the subset of maximal sum in which the distance between consecutive elements is at most 6.
- Practice 2: MinAbsSum at app.codility.com/programmers in C++ Explained: Given array of integers, find the lowest absolute sum of elements.