Pergunta de entrevista da empresa Turing

Medium to easy problem challenge, I solved one of two problems, and I get passed