Pregunta de entrevista de Fortinet

Several alogorithm problems, medium difficulty.