Pergunta de entrevista da empresa Microsoft

Two problems with medium difficulty to solve