Qualcomm interview question

Asked a question similar to the leetcode min-stack problem.