Pregunta de entrevista de Amazon

Two difficult array related questions.