Extreme Networks Interview Question

Leetcode easy, 1854. Pretty standard pair programming interview.