Pregunta de entrevista de DevSoft Philippines

Algorithm question through Hackerrank test