Pergunta de entrevista da empresa YLD

Technical question was building a algorithm that is roughtly medium on leetcode