Morgan Stanley interview question

medium leedcode on data .structures , related to stack