Windward interview question

They explained more than enough to know how to solve the problem even without prior knowledge (only DS and Algorithms)