Pregunta de entrevista de Optiver

there were two hackkerrank coding questions.