Miro Interview Question

Algorithmic Problem with explanation of its complexity.