Rey interview question

Easy level from Leetcode. Make sure you exercise your CS fundamentals.