Smoothstack interview question

Easy/Medium leetcode problem for the Coding Challenge.