Pergunta de entrevista da empresa Bloomberg

question from Leetcode (train schedule ...)