Solution for the running time of the algorithm problem