Nerd Stuff: Map of C++ STL algorithms

And Jesus answered: “Man shall not live on bread alone”. When digging the forest of C++ STL, I found something that is too nerd to not be reshared (I laughed when I saw it). A map of C++ algorithms. The map was made by Jonathan Boccara, this guy has a page in which a lot of good stuff is available to read about C++. And I would recommend if, like me, you are studying some new features of C++ standard template library. [Read More]

Codility MinAvgTwoSlice Solution in C++

Short Premise Find the minimal average of any slice containing at least two elements. Long Premise Slice Definition A non-empty array $A$ consisting of $N$ integers is given. A pair of integers $(P, Q)$, such that $0 \leq P < Q < N$, is called a slice of array $A$ (notice that the slice contains at least two elements). The average of a slice $(P, Q)$ is the sum of $A(P) + A(P + 1) + … + A(Q)$ divided by the length of the slice. [Read More]

Codility BinaryGap Solution in C++

Short Premise Find the maximum consecutive zeros that are surrounded by ones in the binary representation of a number N in a range between 0 and 2.147.483.647. Approach The approach to this solution is to build a state machine that can process the language generated by zeros and ones in a binary number and count the size of all zero gaps. The maximum gap should be computed from all gap values. [Read More]