Pregunta de entrevista de SSENSE

LC questions, hackerrank was 3 hours long