UST Interview Question

Asked to solve a leetcode question.