Skip to main content Link Search Menu Expand Document (external link)

All posts by date

Identifying the maximum in a sliding window

Given an array $x$ and an integer $k$, determine for every index $1 \leq j\leq n$ the maximum $x[i]$ among all indices $\max\{1,j-k+1 \} \leq i \leq j$.

Maintaining sum of k largest items in a dynamic set

Maintain a set, allowing to add or remove elements and to query the sum of the up to k largest items.

Heap allowing to remove items

Maintain a set, allowing to add or remove elements and to query the smallest element.

Parcours en profondeur de Trémaux, parcours main gauche de Pledge

Parcours en profondeur de Trémaux

Query the sum of a submatrix - Fenwick

Maintain a matrix in a datastructure, allowing to update entries and to query the sum of a rectangular submatrix in time $O(\log(n)\log(m))$, where $n,m$ are the dimensions of the matrix.

Count all distinct substrings

Given a string $s$, determine the number of distinct substrings that it contains.

Determine the fixpoint of a rewriting system

Given the a rewriting system of the form $f:\Sigma\rightarrow \Sigma^\star$, determine the limit of $f^i(a)$ for some given seed letter $a\in \Sigma$.

Comment décomposer un nombre en facteurs premiers ?

Étant donné n on veut produire en temps linéaire deux tableaux factor et primes, tel que primes contienne tous les nombres premiers entre 2 et n, et que factor[x] contienne le plus petit facteur de x, avec facteur[x]==x si x est premier.

Recognize a context free language

Given the grammar of a context free language and a string, decide if the string can be generated by the grammar.

Shortest path with negative edge weights

Given directed graph with possibly negative edge weights, find a shortest path between two given vertices.

Bipartite minimum vertex cover (alternative explanation)

Given an undirected bipartite graph find a minimum cardinality vertex set which covers all edges in the sense that it contains at least one endpoint of each edge.

sliding window

Given a string A (or array), and an integer k, find for every index i, the smallest index j (if it exists) such that {A[i],..,A[j-1]} consists of exact k distinct values.

maintaining the median of a dynamic set

Propose a data structure which permits to maintain a set of integers S, allowing to add elements and to remove the median. Both operations should work in logarithmic time.

Trapped rain over a landscape

Given a description of a landscape, describe how the rain water will drain.

Flooding a landscape

Given a description of a landscape, describe how it will be flooded by the water.

Encoding edges by weights

Given a graph, find weights for the vertices if possible, such that there is an edge between two vertices if and only if their total weight exceeds some threshold.

November Rain

You are given $n$ non intersecting line segments in the 2 dimensional plane. The segments are not parallel to the x-axis, nor to the y-axis and segments do not intersect. These segments represent roofs, and it is raining. Water flows down along the roofs, and pours from the lower endpoint to the roof below if there is one. The task is to compute how much water each roof receives.

Union of disjoint rectangles

Given $n$ rectilinear non overlapping rectangles, discovered the all connected components in their union.

How to practice algorithms with tryalgo

Hey, if you want to improve your skills in algorithmic problem solving, you don’t even need an online judge!

Constraint Programming

The framework