Pergunta de entrevista da empresa Amazon

Problem on Monotonic Stack, and Binary Search Tree