Pregunta de entrevista de Amazon

DSA question based on array