UKG Interview Question

leetcode easy question, mostly using lists and linkedlists