Expanse interview question

Leetcode easy question