Javascript recursion and pattern matching with spread operator

Problem

Given an array of measurements ordered by time we have to implement a function that returns an array which will be filled with null measurements for every missing one.

In particular we want at least a measure for each hour after the time the first measure was taken.

This is necessary since we want to display this data in a chart which will try to connect this values with a line and we want to highlight missing measurements problems like in the following image.

Continue reading “Javascript recursion and pattern matching with spread operator”

Find if a list is circular with memory constraint

Usually developers when thinking about a solution put their focus on the complexity of the algorithm (O(n), O(n^2) …) rather than the memory consumption, so lets see an example where the constraint is the memory S.
I would like to share the solution to an interesting exercise that I was asked to solve during a technical interview.

Continue reading “Find if a list is circular with memory constraint”