Pergunta de entrevista da empresa Crossover for Work

They asked me to solve a simple coding challenge (probably from the book CTCI)