Pergunta de entrevista da empresa Teya

Leetcode style coding problem of medium difficulty.