Pregunta de entrevista de Amazon

Question that used a monotonic stack