Pergunta de entrevista da empresa Meta

a variation of simplify path from leet code