Pigment Interview Question

As always, time complexity for the algorithm exercise